Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
platform_tools
android
apps
viewer
src
main
java
org
skia
viewer
ViewerApplication.java
Go to the documentation of this file.
1
/*
2
* Copyright 2015 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
package
org.skia.viewer;
9
10
import
android
.app.Application;
11
import
android
.content.res.AssetManager;
12
13
public
class
ViewerApplication
extends
Application {
14
private
long
mNativeHandle = 0;
15
private
ViewerActivity
mViewerActivity;
16
private
String mStateJsonStr, mTitle;
17
18
static
{
19
System.loadLibrary(
"viewer"
);
20
}
21
22
private
native
long
createNativeApp(AssetManager assetManager);
23
private
native
void
destroyNativeApp(
long
handle);
24
25
@Override
26
public
void
onCreate
() {
27
super.onCreate();
28
mNativeHandle = createNativeApp(this.getResources().getAssets());
29
}
30
31
@Override
32
public
void
onTerminate
() {
33
if
(mNativeHandle != 0) {
34
destroyNativeApp(mNativeHandle);
35
mNativeHandle = 0;
36
}
37
super.onTerminate();
38
}
39
40
public
long
getNativeHandle
() {
41
return
mNativeHandle;
42
}
43
44
public
void
setViewerActivity
(
ViewerActivity
viewerActivity) {
45
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
}
57
58
public
void
setTitle
(String title) {
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
}
63
if
(mViewerActivity !=
null
) {
64
mViewerActivity.runOnUiThread(
new
Runnable() {
65
@Override
66
public
void
run
() {
67
mViewerActivity.setTitle(mTitle);
68
}
69
});
70
}
71
}
72
73
public
void
setState
(String stateJsonStr) {
74
// We have to store this state because ViewerActivity may be destroyed while the native app
75
// is still running. When a new ViewerActivity is created, we'll pass the state to it.
76
mStateJsonStr = stateJsonStr;
77
if
(mViewerActivity !=
null
) {
78
mViewerActivity.runOnUiThread(
new
Runnable() {
79
@Override
80
public
void
run
() {
81
mViewerActivity.
setState
(mStateJsonStr);
82
}
83
});
84
}
85
}
86
}
org.skia.viewer.ViewerActivity
Definition
ViewerActivity.java:27
org.skia.viewer.ViewerActivity.setState
void setState(String stateJson)
Definition
ViewerActivity.java:153
org.skia.viewer.ViewerApplication
Definition
ViewerApplication.java:13
org.skia.viewer.ViewerApplication.setTitle
void setTitle(String title)
Definition
ViewerApplication.java:58
org.skia.viewer.ViewerApplication.onCreate
void onCreate()
Definition
ViewerApplication.java:26
org.skia.viewer.ViewerApplication.onTerminate
void onTerminate()
Definition
ViewerApplication.java:32
org.skia.viewer.ViewerApplication.setState
void setState(String stateJsonStr)
Definition
ViewerApplication.java:73
org.skia.viewer.ViewerApplication.setViewerActivity
void setViewerActivity(ViewerActivity viewerActivity)
Definition
ViewerApplication.java:44
org.skia.viewer.ViewerApplication.getNativeHandle
long getNativeHandle()
Definition
ViewerApplication.java:40
android
Definition
BitmapRegionDecoder.cpp:14
run
Definition
run.py:1
Generated on Fri Apr 26 2024 06:16:31 for Flutter Engine by
1.9.8