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

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

Issue 2004633002: Add drawer with state information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge Created 4 years, 7 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: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java
diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java
index 4b890bd5e1279cb2437a205d581b54aa04dffabc..ee1695afd1e9cd60fe25a0d44bd8a1ef271a023e 100644
--- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java
+++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java
@@ -12,6 +12,7 @@ import android.app.Application;
public class ViewerApplication extends Application {
private long mNativeHandle = 0;
private ViewerActivity mViewerActivity;
+ private String mStateJsonStr, mTitle;
static {
System.loadLibrary("skia_android");
@@ -41,16 +42,40 @@ public class ViewerApplication extends Application {
}
public void setViewerActivity(ViewerActivity viewerActivity) {
- this.mViewerActivity = viewerActivity;
+ mViewerActivity = viewerActivity;
+ // Note that viewerActivity might be null (called by onDestroy)
+ if (mViewerActivity != null) {
+ // A new ViewerActivity is created; initialize its state and title
+ if (mStateJsonStr != null) {
+ mViewerActivity.setState(mStateJsonStr);
+ }
+ if (mTitle != null) {
+ mViewerActivity.setTitle(mTitle);
+ }
+ }
}
public void setTitle(String title) {
- final String finalTitle = title;
+ mTitle = title; // Similar to mStateJsonStr, we have to store this.
+ if (mViewerActivity != null) {
+ mViewerActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mViewerActivity.setTitle(mTitle);
+ }
+ });
+ }
+ }
+
+ public void setState(String stateJsonStr) {
+ // We have to store this state because ViewerActivity may be destroyed while the native app
+ // is still running. When a new ViewerActivity is created, we'll pass the state to it.
+ mStateJsonStr = stateJsonStr;
if (mViewerActivity != null) {
mViewerActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
- mViewerActivity.setTitle(finalTitle);
+ mViewerActivity.setState(mStateJsonStr);
}
});
}

Powered by Google App Engine
This is Rietveld 408576698