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

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: Review comments 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
« no previous file with comments | « sky/engine/core/script/dart_controller.cc ('k') | sky/framework/shell.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..80879a54ddd6dfa0a907f4315df95f4622f74a67
--- /dev/null
+++ b/sky/examples/shell/sensor.sky
@@ -0,0 +1,38 @@
+<script>
+import '/sky/framework/shell.dart' as shell;
+import 'dart:sky';
+import 'package:sky/services/sensors/sensors.mojom.dart';
+
+class MyListener extends SensorListener {
+ int count = 0;
+
+ 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>Shake me.</div>
« no previous file with comments | « sky/engine/core/script/dart_controller.cc ('k') | sky/framework/shell.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698