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

Side by Side Diff: sky/sdk/lib/example/raw/launcher.dart

Issue 1210173004: Move examples to //sky/sdk/example (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/sdk/lib/example/raw/hello_world.dart ('k') | sky/sdk/lib/example/raw/painting.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 import "dart:math";
6 import 'dart:sky';
7
8 import 'package:sky/framework/shell.dart' as shell;
9 import 'package:mojom/intents/intents.mojom.dart';
10
11 Picture draw(int a, int r, int g, int b) {
12 Size size = new Size(view.width, view.height);
13
14 PictureRecorder recorder = new PictureRecorder();
15 Canvas canvas = new Canvas(recorder, size);
16 double radius = size.shortestSide * 0.45;
17
18 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
19 canvas.drawRect(new Rect.fromSize(size), paint);
20 return recorder.endRecording();
21 }
22
23 bool handleEvent(Event event) {
24 if (event.type == "pointerdown") {
25 view.picture = draw(255, 0, 0, 255);
26 view.scheduleFrame();
27 return true;
28 }
29
30 if (event.type == "pointerup") {
31 view.picture = draw(255, 255, 255, 0);
32 view.scheduleFrame();
33
34 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
35 Intent intent = new Intent()
36 ..action = 'android.intent.action.VIEW'
37 ..url = 'sky://localhost:9888/sky/sdk/lib/example/raw/hello_world.dart';
38 shell.requestService(null, activityManager);
39 activityManager.ptr.startActivity(intent);
40 return true;
41 }
42
43 if (event.type == "back") {
44 print("Pressed back button.");
45 return true;
46 }
47
48 return false;
49 }
50
51 void main() {
52 print("Hello, world");
53 view.picture = draw(255, 255, 255, 0);
54 view.scheduleFrame();
55
56 view.setEventCallback(handleEvent);
57 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/example/raw/hello_world.dart ('k') | sky/sdk/lib/example/raw/painting.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698