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

Side by Side Diff: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java

Issue 2016343002: Revert of Add drawer with state information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 package org.skia.viewer; 8 package org.skia.viewer;
9 9
10 import android.app.Application; 10 import android.app.Application;
11 11
12 public class ViewerApplication extends Application { 12 public class ViewerApplication extends Application {
13 private long mNativeHandle = 0; 13 private long mNativeHandle = 0;
14 private ViewerActivity mViewerActivity; 14 private ViewerActivity mViewerActivity;
15 private String mStateJsonStr, mTitle;
16 15
17 static { 16 static {
18 System.loadLibrary("skia_android"); 17 System.loadLibrary("skia_android");
19 System.loadLibrary("viewer"); 18 System.loadLibrary("viewer");
20 } 19 }
21 20
22 private native long createNativeApp(); 21 private native long createNativeApp();
23 private native void destroyNativeApp(long handle); 22 private native void destroyNativeApp(long handle);
24 23
25 @Override 24 @Override
26 public void onCreate() { 25 public void onCreate() {
27 super.onCreate(); 26 super.onCreate();
28 mNativeHandle = createNativeApp(); 27 mNativeHandle = createNativeApp();
29 } 28 }
30 29
31 @Override 30 @Override
32 public void onTerminate() { 31 public void onTerminate() {
33 if (mNativeHandle != 0) { 32 if (mNativeHandle != 0) {
34 destroyNativeApp(mNativeHandle); 33 destroyNativeApp(mNativeHandle);
35 mNativeHandle = 0; 34 mNativeHandle = 0;
36 } 35 }
37 super.onTerminate(); 36 super.onTerminate();
38 } 37 }
39 38
40 public long getNativeHandle() { 39 public long getNativeHandle() {
41 return mNativeHandle; 40 return mNativeHandle;
42 } 41 }
43 42
44 public void setViewerActivity(ViewerActivity viewerActivity) { 43 public void setViewerActivity(ViewerActivity viewerActivity) {
45 mViewerActivity = viewerActivity; 44 this.mViewerActivity = viewerActivity;
46 // Note that viewerActivity might be null (called by onDestroy)
47 if (mViewerActivity != null) {
48 // A new ViewerActivity is created; initialize its state and title
49 if (mStateJsonStr != null) {
50 mViewerActivity.setState(mStateJsonStr);
51 }
52 if (mTitle != null) {
53 mViewerActivity.setTitle(mTitle);
54 }
55 }
56 } 45 }
57 46
58 public void setTitle(String title) { 47 public void setTitle(String title) {
59 mTitle = title; // Similar to mStateJsonStr, we have to store this. 48 final String finalTitle = title;
60 if (mViewerActivity != null) { 49 if (mViewerActivity != null) {
61 mViewerActivity.runOnUiThread(new Runnable() { 50 mViewerActivity.runOnUiThread(new Runnable() {
62 @Override 51 @Override
63 public void run() { 52 public void run() {
64 mViewerActivity.setTitle(mTitle); 53 mViewerActivity.setTitle(finalTitle);
65 } 54 }
66 }); 55 });
67 } 56 }
68 }
69
70 public void setState(String stateJsonStr) {
71 // We have to store this state because ViewerActivity may be destroyed w hile the native app
72 // is still running. When a new ViewerActivity is created, we'll pass th e state to it.
73 mStateJsonStr = stateJsonStr;
74 if (mViewerActivity != null) {
75 mViewerActivity.runOnUiThread(new Runnable() {
76 @Override
77 public void run() {
78 mViewerActivity.setState(mStateJsonStr);
79 }
80 });
81 }
82 } 57 }
83 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698