Source:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); webView.clearCache(true); webView.getSettings().setJavaScriptEnabled(true); URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), webView) { private boolean didReceiveError = false; @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { didReceiveError = true; hideLoadingProgress(); pageIsLoaded = false; ViewPagerDownloadManager.instance.done(CourseUnitWebviewFragment.this, false); setFragmentState(true); } @TargetApi(23) public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { didReceiveError = true; switch (errorResponse.getStatusCode()) { case HttpURLConnection.HTTP_FORBIDDEN: case HttpURLConnection.HTTP_UNAUTHORIZED: case HttpURLConnection.HTTP_NOT_FOUND: EdxCookieManager.getSharedInstance().tryToRefreshSessionCookie(); break; } } public void onPageFinished(WebView view, String url) { if (didReceiveError) { didReceiveError = false; return; } if (url != null && url.equals("data:text/html," + EMPTY_HTML)) { } else { pageIsLoaded = true; } ViewPagerDownloadManager.instance.done(CourseUnitWebviewFragment.this, true); hideLoadingProgress(); } }; client.setAllLinksAsExternal(true); if( ViewPagerDownloadManager.USING_UI_PRELOADING ) { if (ViewPagerDownloadManager.instance.inInitialPhase(unit)) { ViewPagerDownloadManager.instance.addTask(this); } else { tryToLoadWebView(true); } } }

Target:
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); webView.clearCache(true); webView.getSettings().setJavaScriptEnabled(true); URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), webView) { private boolean didReceiveError = false; @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { didReceiveError = true; hideLoadingProgress(); pageIsLoaded = false; ViewPagerDownloadManager.instance.done(CourseUnitWebviewFragment.this, false); showErrorMessage(R.string.network_error_message, FontAwesomeIcons.fa_exclamation_circle); } @Override @TargetApi(Build.VERSION_CODES.M) public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { didReceiveError = true; switch (errorResponse.getStatusCode()) { case HttpURLConnection.HTTP_FORBIDDEN: case HttpURLConnection.HTTP_UNAUTHORIZED: case HttpURLConnection.HTTP_NOT_FOUND: EdxCookieManager.getSharedInstance().tryToRefreshSessionCookie(); break; } showErrorMessage(R.string.network_error_message, FontAwesomeIcons.fa_exclamation_circle); } public void onPageFinished(WebView view, String url) { if (didReceiveError) { didReceiveError = false; return; } if (url != null && url.equals("data:text/html," + EMPTY_HTML)) { } else { pageIsLoaded = true; } ViewPagerDownloadManager.instance.done(CourseUnitWebviewFragment.this, true); hideLoadingProgress(); } }; client.setAllLinksAsExternal(true); if( ViewPagerDownloadManager.USING_UI_PRELOADING ) { if (ViewPagerDownloadManager.instance.inInitialPhase(unit)) { ViewPagerDownloadManager.instance.addTask(this); } else { tryToLoadWebView(true); } } }