OLD | NEW |
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; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 mViewerActivity.setState(mStateJsonStr); | 50 mViewerActivity.setState(mStateJsonStr); |
51 } | 51 } |
52 if (mTitle != null) { | 52 if (mTitle != null) { |
53 mViewerActivity.setTitle(mTitle); | 53 mViewerActivity.setTitle(mTitle); |
54 } | 54 } |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 public void setTitle(String title) { | 58 public void setTitle(String title) { |
59 mTitle = title; // Similar to mStateJsonStr, we have to store this. | 59 mTitle = title; // Similar to mStateJsonStr, we have to store this. |
| 60 if (mTitle.startsWith("Viewer: ")) { // Quick hack to shorten the title |
| 61 mTitle = mTitle.replaceFirst("Viewer: ", ""); |
| 62 } |
60 if (mViewerActivity != null) { | 63 if (mViewerActivity != null) { |
61 mViewerActivity.runOnUiThread(new Runnable() { | 64 mViewerActivity.runOnUiThread(new Runnable() { |
62 @Override | 65 @Override |
63 public void run() { | 66 public void run() { |
64 mViewerActivity.setTitle(mTitle); | 67 mViewerActivity.setTitle(mTitle); |
65 } | 68 } |
66 }); | 69 }); |
67 } | 70 } |
68 } | 71 } |
69 | 72 |
70 public void setState(String stateJsonStr) { | 73 public void setState(String stateJsonStr) { |
71 // We have to store this state because ViewerActivity may be destroyed w
hile the native app | 74 // 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. | 75 // is still running. When a new ViewerActivity is created, we'll pass th
e state to it. |
73 mStateJsonStr = stateJsonStr; | 76 mStateJsonStr = stateJsonStr; |
74 if (mViewerActivity != null) { | 77 if (mViewerActivity != null) { |
75 mViewerActivity.runOnUiThread(new Runnable() { | 78 mViewerActivity.runOnUiThread(new Runnable() { |
76 @Override | 79 @Override |
77 public void run() { | 80 public void run() { |
78 mViewerActivity.setState(mStateJsonStr); | 81 mViewerActivity.setState(mStateJsonStr); |
79 } | 82 } |
80 }); | 83 }); |
81 } | 84 } |
82 } | 85 } |
83 } | 86 } |
OLD | NEW |