Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: sky/framework/debug/shake-to-reload.sky

Issue 1093033002: Add sensors application to mojo (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Support both SkyDemo and mojo_shell Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <script> 1 <script>
2 import 'dart:sky'; 2 import 'dart:sky';
3 import 'package:sensors/sensors.mojom.dart';
3 import 'package:sky/framework/shell.dart' as shell; 4 import 'package:sky/framework/shell.dart' as shell;
4 import 'package:sky/services/sensors/sensors.mojom.dart';
5 5
6 // TODO(abarth): We should factor this out into a kinematics library. 6 // TODO(abarth): We should factor this out into a kinematics library.
7 class _ShakeDetector extends SensorListener { 7 class _ShakeDetector implements SensorListener {
8 _ShakeDetector() { 8 _ShakeDetector() {
9 SensorServiceProxy sensorService = new SensorServiceProxy.unbound(); 9 SensorServiceProxy sensorService = new SensorServiceProxy.unbound();
10 shell.requestService(sensorService); 10 shell.requestService("mojo:sensors", sensorService);
11 11
12 _stub = new SensorListenerStub.unbound()..impl = this; 12 _stub = new SensorListenerStub.unbound()..impl = this;
13 sensorService.ptr.addListener(SensorType_ACCELEROMETER, _stub); 13 sensorService.ptr.addListener(SensorType_ACCELEROMETER, _stub);
14 } 14 }
15 15
16 void onAccuracyChanged(int accuracy) { 16 void onAccuracyChanged(int accuracy) {
17 } 17 }
18 18
19 void onSensorChanged(SensorData data) { 19 void onSensorChanged(SensorData data) {
20 double value = data.values[0] + data.values[1] + data.values[2]; 20 double value = data.values[0] + data.values[1] + data.values[2];
21 print("onSensorChanged: $value");
qsr 2015/04/21 08:28:45 Is that voluntary?
DaveMoore 2015/04/21 15:00:07 Accident (was for testing). I'll remove.
21 if (isShaking && value < 15.0) 22 if (isShaking && value < 15.0)
22 didCompleteShake(); 23 didCompleteShake();
23 else if (value > 40.0) 24 else if (value > 40.0)
24 isShaking = true; 25 isShaking = true;
25 } 26 }
26 27
27 void didCompleteShake() { 28 void didCompleteShake() {
28 window.location.assign(document.URL); 29 window.location.assign(document.URL);
29 _stub.close(); 30 _stub.close();
30 } 31 }
31 32
32 bool isShaking = false; 33 bool isShaking = false;
33 SensorListenerStub _stub; 34 SensorListenerStub _stub;
34 } 35 }
35 36
36 _ShakeDetector _detector; 37 _ShakeDetector _detector;
37 38
38 void _init(_) { 39 void _init(_) {
39 _detector = new _ShakeDetector(); 40 _detector = new _ShakeDetector();
40 } 41 }
41 </script> 42 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698