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

Unified Diff: sky/examples/shell/sensor.sky

Issue 962043002: Expose Android sensors to via Mojo services (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Cleaner Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sky/examples/shell/sensor.sky
diff --git a/sky/examples/shell/sensor.sky b/sky/examples/shell/sensor.sky
new file mode 100644
index 0000000000000000000000000000000000000000..5690372cc24ca6074ff0e243fdf9c635d23a3469
--- /dev/null
+++ b/sky/examples/shell/sensor.sky
@@ -0,0 +1,37 @@
+<script>
+import '/sky/framework/shell.dart' as shell;
+import 'dart:sky';
+import 'package:sky/services/sensors/sensors.mojom.dart';
+
+int count = 0;
eseidel 2015/02/27 22:29:25 member
+
+class MyListener extends SensorListener {
+ void onAccuracyChanged(int accuracy) {
+ print("onAccuracyChanged $accuracy");
+ }
+ void onSensorChanged(SensorData data) {
+ double value = data.values[0] + data.values[1] + data.values[2];
+ if (value > 40.0) {
+ document.querySelector('div').textContent =
+ "Shake count " + (count++).toString();
+ }
+ }
+
+ MyListener.unbound() {
+ stub = new SensorListenerStub.unbound()
+ ..delegate = this;
+ }
+
+ SensorListenerStub stub;
+}
+
+void main() {
+ var sensorService = new SensorServiceProxy.unbound();
+ shell.requestService(sensorService);
+
+ var listener = new MyListener.unbound();
+ sensorService.ptr.addListener(SensorType_ACCELEROMETER, listener.stub);
+ listener.stub.listen();
+}
+</script>
+<div>Hello, world.</div>
eseidel 2015/02/27 22:29:25 Instructions here?

Powered by Google App Engine
This is Rietveld 408576698