Revision ef2709dc
Added by Leszek Koltunski 11 months ago
src/main/java/org/distorted/tutorials/TutorialActivity.java | ||
---|---|---|
51 | 51 |
private int mObjectOrdinal; |
52 | 52 |
private TutorialWebView mWebView; |
53 | 53 |
private boolean mIsFree; |
54 |
private boolean mErrorLoadingWebView; |
|
54 | 55 |
|
55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 57 |
|
... | ... | |
60 | 61 |
super.onCreate(savedState); |
61 | 62 |
DistortedLibrary.onCreate(ACTIVITY_NUMBER); |
62 | 63 |
setTheme(R.style.MaterialThemeNoActionBar); |
63 |
setContentView(R.layout.tutorial); |
|
64 |
|
|
65 |
try |
|
66 |
{ |
|
67 |
setContentView(R.layout.tutorial); |
|
68 |
mErrorLoadingWebView = false; |
|
69 |
} |
|
70 |
catch(Exception e) |
|
71 |
{ |
|
72 |
setContentView(R.layout.tutorial_no_webview); |
|
73 |
mErrorLoadingWebView = true; |
|
74 |
} |
|
64 | 75 |
|
65 | 76 |
mIsFree = true; |
66 | 77 |
|
... | ... | |
87 | 98 |
|
88 | 99 |
public void showDialog() |
89 | 100 |
{ |
90 |
Bundle bundle = new Bundle(); |
|
91 |
bundle.putString("argument", String.valueOf(mObjectOrdinal) ); |
|
92 |
RubikDialogTutorial diag = new RubikDialogTutorial(); |
|
93 |
diag.setArguments(bundle); |
|
94 |
diag.show( getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() ); |
|
101 |
if( !mErrorLoadingWebView ) |
|
102 |
{ |
|
103 |
Bundle bundle = new Bundle(); |
|
104 |
bundle.putString("argument", String.valueOf(mObjectOrdinal)); |
|
105 |
RubikDialogTutorial diag = new RubikDialogTutorial(); |
|
106 |
diag.setArguments(bundle); |
|
107 |
diag.show(getSupportFragmentManager(), RubikDialogTutorial.getDialogTag()); |
|
108 |
} |
|
95 | 109 |
} |
96 | 110 |
|
97 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
124 | 138 |
|
125 | 139 |
public void loadTutorial(String url) |
126 | 140 |
{ |
127 |
if( mWebView==null )
|
|
141 |
if( !mErrorLoadingWebView )
|
|
128 | 142 |
{ |
129 |
WebView videoView = findViewById(R.id.tutorialVideoView); |
|
130 |
mWebView = new TutorialWebView(videoView); |
|
131 |
} |
|
143 |
if(mWebView==null) |
|
144 |
{ |
|
145 |
WebView videoView = findViewById(R.id.tutorialVideoView); |
|
146 |
mWebView = new TutorialWebView(videoView); |
|
147 |
} |
|
132 | 148 |
|
133 |
mWebView.load(URL+url); |
|
149 |
mWebView.load(URL+url); |
|
150 |
} |
|
134 | 151 |
} |
135 | 152 |
|
136 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/layout/tutorial_no_webview.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="match_parent" |
|
4 |
android:layout_height="match_parent" |
|
5 |
android:layout_marginLeft="0dp" |
|
6 |
android:layout_marginRight="0dp" |
|
7 |
android:background="@android:color/transparent" |
|
8 |
android:orientation="vertical" > |
|
9 |
|
|
10 |
<TextView |
|
11 |
android:id="@+id/tutorialError" |
|
12 |
android:layout_width="match_parent" |
|
13 |
android:text="@string/webview_error" |
|
14 |
android:gravity="center" |
|
15 |
android:layout_height="0dp" |
|
16 |
android:layout_weight="1"/> |
|
17 |
|
|
18 |
<RelativeLayout |
|
19 |
android:id="@+id/tutorialLowerPart" |
|
20 |
android:layout_width="match_parent" |
|
21 |
android:layout_height="0dp" |
|
22 |
android:layout_weight="1.2"> |
|
23 |
|
|
24 |
<org.distorted.tutorials.TutorialSurfaceView |
|
25 |
android:id="@+id/tutorialSurfaceView" |
|
26 |
android:layout_width="match_parent" |
|
27 |
android:layout_height="match_parent" |
|
28 |
android:layout_alignParentStart="true"/> |
|
29 |
|
|
30 |
<LinearLayout |
|
31 |
android:id="@+id/tutorialRightBar" |
|
32 |
android:layout_alignParentRight="true" |
|
33 |
android:layout_width="0dp" |
|
34 |
android:layout_height="match_parent" |
|
35 |
android:orientation="vertical" |
|
36 |
android:background="@android:color/transparent"> |
|
37 |
</LinearLayout> |
|
38 |
|
|
39 |
</RelativeLayout> |
|
40 |
</LinearLayout> |
|
41 |
|
src/main/res/values/strings.xml | ||
---|---|---|
109 | 109 |
<string name="config_mesh_fast">Fast</string> |
110 | 110 |
<string name="config_mesh_nice">Nice</string> |
111 | 111 |
|
112 |
<string name="webview_error" translatable="false">Error Loading WebView</string> |
|
112 | 113 |
<string name="opengl_error" translatable="false">Error</string> |
113 | 114 |
<string name="opengl_error_text" translatable="false">This device does not support OpenGL 3.0</string> |
114 | 115 |
|
Also available in: Unified diff
Catch the error when WebView is not installed.