Source:
<code>private void setUpWebView(View view) { mProgressBar = (ProgressBar) view.findViewById(R.id.progress); mWebView.setBackgroundColor(Color.TRANSPARENT); mWebView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(getActivity())) { @Override public void onPageStarted(android.webkit.WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (getActivity() != null) { getActivity().invalidateOptionsMenu(); } } @Override public void onPageFinished(android.webkit.WebView view, String url) { super.onPageFinished(view, url); if (getActivity() != null) { getActivity().invalidateOptionsMenu(); } } }); mWebView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(android.webkit.WebView view, int newProgress) { super.onProgressChanged(view, newProgress); mProgressBar.setProgress(newProgress); mProgressBar.setVisibility(newProgress == 100 ? GONE : VISIBLE); mButtonRefresh.setImageResource(newProgress == 100 ? R.drawable.ic_refresh_white_24dp : R.drawable.ic_clear_white_24dp); } }); mWebView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> { if (isPdfRenderingSupported() && mimetype.equals(PDF_MIME_TYPE)) { downloadFileAndRenderPdf(); } else { if (getActivity() == null) { return; <START> } <END> final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (intent.resolveActivity(getActivity().getPackageManager()) == null) { return; } mExternalRequired = true; mWebView.setVisibility(GONE); view.findViewById(R.id.empty).setVisibility(VISIBLE); view.findViewById(R.id.download_button).setOnClickListener(v -> startActivity(intent)); } }); AppUtils.toggleWebViewZoom(mWebView.getSettings(), false); }</code><technical_language>This early termination top of callback, context (activity here) do else</technical_language>

Target:
private void setUpWebView(View view) { mProgressBar = (ProgressBar) view.findViewById(R.id.progress); mWebView.setBackgroundColor(Color.TRANSPARENT); mWebView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(getActivity())) { @Override public void onPageStarted(android.webkit.WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (getActivity() != null) { getActivity().invalidateOptionsMenu(); } } @Override public void onPageFinished(android.webkit.WebView view, String url) { super.onPageFinished(view, url); if (getActivity() != null) { getActivity().invalidateOptionsMenu(); } } }); mWebView.setWebChromeClient(new CacheableWebView.ArchiveClient() { @Override public void onProgressChanged(android.webkit.WebView view, int newProgress) { super.onProgressChanged(view, newProgress); mProgressBar.setProgress(newProgress); mProgressBar.setVisibility(newProgress == 100 ? GONE : VISIBLE); mButtonRefresh.setImageResource(newProgress == 100 ? R.drawable.ic_refresh_white_24dp : R.drawable.ic_clear_white_24dp); } }); mWebView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> { if (getActivity() == null) { return; } if (isPdfRenderingSupported() && mimetype.equals(PDF_MIME_TYPE)) { downloadFileAndRenderPdf(); } else { offerExternalApp(); } }); AppUtils.toggleWebViewZoom(mWebView.getSettings(), false); }