Source:
public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); super.setToolbarAsActionBar(); final Uri intentData = getIntent().getData(); if (intentData != null && AppConstants.APP_URI_SCHEME.startsWith(intentData.getScheme())) { final String title = intentData.getHost(); final String url = intentData.getQueryParameter(PARAM_INTENT_FILE_LINK); getIntent().putExtra(ARG_URL, url).putExtra(ARG_TITLE, title); } final ProgressBar progress = (ProgressBar) findViewById(R.id.loading_indicator); progress.setVisibility(View.GONE); webView = (WebView) findViewById(R.id.webView); final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView); client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() { @Override public void onPageStarted() { progress.setVisibility(View.VISIBLE); } @Override public void onPageFinished() { progress.setVisibility(View.GONE); } @Override public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) { progress.setVisibility(View.GONE); } @Override public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) { if (isMainRequestFailure) { progress.setVisibility(View.GONE); } } @Override public void onPageLoadProgressChanged(WebView view, int progressPercent) { if (progressPercent > 50) progress.setVisibility(View.GONE); } }); webView.loadUrl(getIntent().getStringExtra(ARG_URL)); final String title = getIntent().getStringExtra(ARG_TITLE); if (!TextUtils.isEmpty(title)) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle(title); } }

Target:
public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); super.setToolbarAsActionBar(); final Uri intentData = getIntent().getData(); if (intentData != null && AppConstants.APP_URI_SCHEME.startsWith(intentData.getScheme())) { final String title = intentData.getHost(); final String url = intentData.getQueryParameter(PARAM_INTENT_FILE_LINK); getIntent().putExtra(ARG_URL, url).putExtra(ARG_TITLE, title); } final ProgressBar progress = (ProgressBar) findViewById(R.id.loading_indicator); progress.setVisibility(View.GONE); webView = (WebView) findViewById(R.id.webView); final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView); client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() { @Override public void onPageStarted() { progress.setVisibility(View.VISIBLE); } @Override public void onPageFinished() { progress.setVisibility(View.GONE); } @Override public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) { progress.setVisibility(View.GONE); } @Override public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) { if (isMainRequestFailure) { progress.setVisibility(View.GONE); } } @Override public void onPageLoadProgressChanged(WebView view, int progressPercent) { if (progressPercent > AppConstants.PAGE_LOAD_THRESHOLD) progress.setVisibility(View.GONE); } }); webView.loadUrl(getIntent().getStringExtra(ARG_URL)); final String title = getIntent().getStringExtra(ARG_TITLE); if (!TextUtils.isEmpty(title)) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle(title); } }