12
12
import android .os .Build ;
13
13
import android .os .Handler ;
14
14
import android .os .Message ;
15
- import android .util .Log ;
16
15
import android .webkit .CookieManager ;
17
16
import android .webkit .WebChromeClient ;
18
17
import android .webkit .WebResourceError ;
@@ -144,31 +143,27 @@ public void onProgressChanged(WebView view, int newProgress) {
144
143
@ Override
145
144
public void onPageStarted (WebView view , String url , Bitmap favicon ) {
146
145
super .onPageStarted (view , url , favicon );
147
- Log .d ("TAG" , "started url: " +url );
148
146
handleUrlLoad (view , url );
149
147
}
150
148
151
149
// handle loading error by showing the offline screen
152
150
@ Deprecated
153
151
@ Override
154
152
public void onReceivedError (WebView view , int errorCode , String description , String failingUrl ) {
155
- Log .d ("TAG" , "receivedError Old" );
156
153
if (Build .VERSION .SDK_INT < Build .VERSION_CODES .M ) {
157
- handleLoadError (view , failingUrl , errorCode );
154
+ handleLoadError (errorCode );
158
155
}
159
156
}
160
157
161
158
@ TargetApi (Build .VERSION_CODES .M )
162
159
@ Override
163
160
public void onReceivedError (WebView view , WebResourceRequest request , WebResourceError error ) {
164
- Log .d ("TAG" , "receivedError New" );
165
161
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
166
162
// new API method calls this on every error for each resource.
167
163
// we only want to interfere if the page itself got problems.
168
164
String url = request .getUrl ().toString ();
169
165
if (view .getUrl ().equals (url )) {
170
- Log .d ("TAG" , "receivedError New page match " + error .getDescription ().toString ());
171
- handleLoadError (view , url , error .getErrorCode ());
166
+ handleLoadError (error .getErrorCode ());
172
167
}
173
168
}
174
169
}
@@ -192,11 +187,10 @@ private void showNoAppDialog(Activity thisActivity) {
192
187
.show ();
193
188
}
194
189
// handle load errors
195
- private void handleLoadError (WebView view , String url , int errorCode ) {
190
+ private void handleLoadError (int errorCode ) {
196
191
if (errorCode != WebViewClient .ERROR_UNSUPPORTED_SCHEME ) {
197
192
uiManager .setOffline (true );
198
193
} else {
199
- Log .d ("TAG" , "unsupported scheme!" );
200
194
// Unsupported Scheme, recover
201
195
new Handler ().postDelayed (new Runnable () {
202
196
@ Override
@@ -214,15 +208,6 @@ private boolean handleUrlLoad(WebView view, String url) {
214
208
// stop loading
215
209
view .stopLoading ();
216
210
217
- /*
218
- // handle non-http protocols, like mailto: or whatsapp:
219
- if (!url.startsWith("http")) {
220
- // this hit the WebView's onReceivedError callback, recover
221
- goBack();
222
- uiManager.setOffline(false);
223
- }
224
- */
225
-
226
211
// open external URL in Browser/3rd party apps instead
227
212
try {
228
213
Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (url ));
0 commit comments