mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
ShoeRecordActivity.this.showDialog(null, "载入中,请稍后...");
logger.info("onPageStarted() called with: " + "view = [" + view + "], url = [" + url + "], favicon = [" + favicon + "]");
}
@Override
public void onPageFinished(WebView view, String url) {
String javaScript = "javascript:function annotationData(){" +
"var x=document.getElementById(\"accomTotalDistance\"); x.innerHTML=" + "'" + dis + "km" + "'" + ";" +
"var y=document.getElementById(\"accomPace\"); y.innerHTML=" + "'" + pace2 + "'" + ";" +
"var z=document.getElementById(\"accomRecordAccount\"); z.innerHTML=" + "'" + record + "'" + ";" +
"var a=document.getElementById(\"processDiv\"); a.style.width=" + "'" + progress + "%" + "'" + ";" +
"}";
logger.error("onPageFinished() returned: " + javaScript);
mWebView.loadUrl(javaScript);
mWebView.loadUrl("javascript:annotationData()");
super.onPageFinished(view, url);
if (dialog.isShowing() && dialog != null) {
dialog.cancel();
}
}
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
});
mWebView.loadUrl(mURL);