diff options
author | liyuqian <liyuqian@google.com> | 2016-05-13 09:57:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-13 09:57:44 -0700 |
commit | 36632f46a6d87d9d9bd5e0ab65350638e8cfb65c (patch) | |
tree | e63fc382ec6f7e0954e434bd5d9f03c49ae7a4c2 /platform_tools/android/apps | |
parent | 9fb420393ee1c24fc3282b7155985fa8fa7bcad4 (diff) |
Change Android activity title from JNI call
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1978843002
Review-Url: https://codereview.chromium.org/1978843002
Diffstat (limited to 'platform_tools/android/apps')
-rw-r--r-- | platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java | 7 | ||||
-rw-r--r-- | platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerApplication.java | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java index e3260c25f7..d6fe710aeb 100644 --- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java +++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java @@ -60,6 +60,7 @@ public class ViewerActivity setContentView(R.layout.activity_main); mApplication = (ViewerApplication) getApplication(); + mApplication.setViewerActivity(this); mView = (SurfaceView) findViewById(R.id.surfaceView); mView.getHolder().addCallback(this); @@ -67,6 +68,12 @@ public class ViewerActivity } @Override + protected void onDestroy() { + mApplication.setViewerActivity(null); + super.onDestroy(); + } + + @Override public void surfaceCreated(SurfaceHolder holder) { if (mApplication.getNativeHandle() != 0) { onSurfaceCreated(mApplication.getNativeHandle(), holder.getSurface()); 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 9389f72208..4b890bd5e1 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 @@ -11,6 +11,7 @@ import android.app.Application; public class ViewerApplication extends Application { private long mNativeHandle = 0; + private ViewerActivity mViewerActivity; static { System.loadLibrary("skia_android"); @@ -38,4 +39,20 @@ public class ViewerApplication extends Application { public long getNativeHandle() { return mNativeHandle; } + + public void setViewerActivity(ViewerActivity viewerActivity) { + this.mViewerActivity = viewerActivity; + } + + public void setTitle(String title) { + final String finalTitle = title; + if (mViewerActivity != null) { + mViewerActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mViewerActivity.setTitle(finalTitle); + } + }); + } + } } |