use of android.webkit.WebChromeClient in project LookLook by xinghongfei.
the class ZhihuDescribeActivity method initView.
private void initView() {
mToolbar.setTitleMargin(20, 20, 0, 10);
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
mToolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mNest.smoothScrollTo(0, 0);
}
});
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandImageAndFinish();
}
});
mTranslateYTextView.setText(title);
WebSettings settings = wvZhihu.getSettings();
settings.setJavaScriptEnabled(true);
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
//settings.setUseWideViewPort(true);造成文字太小
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setAppCachePath(getCacheDir().getAbsolutePath() + "/webViewCache");
settings.setAppCacheEnabled(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
wvZhihu.setWebChromeClient(new WebChromeClient());
}
use of android.webkit.WebChromeClient in project BookReader by JustWayward.
the class ProgressWebView method initWebview.
private void initWebview(String url) {
mWebView.addJavascriptInterface(this, "android");
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
// 设置可以访问文件
webSettings.setAllowFileAccess(true);
// 设置可以支持缩放
webSettings.setSupportZoom(true);
// 设置默认缩放方式尺寸是far
webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
// 设置出现缩放工具
webSettings.setBuiltInZoomControls(false);
webSettings.setDefaultFontSize(16);
mWebView.loadUrl(url);
// 设置WebViewClient
mWebView.setWebViewClient(new WebViewClient() {
// url拦截
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 使用自己的WebView组件来响应Url加载事件,而不是使用默认浏览器器加载页面
view.loadUrl(url);
// 相应完成返回true
return true;
// return super.shouldOverrideUrlLoading(view, url);
}
// 页面开始加载
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
mProgressBar.setVisibility(View.VISIBLE);
super.onPageStarted(view, url, favicon);
}
// 页面加载完成
@Override
public void onPageFinished(WebView view, String url) {
mProgressBar.setVisibility(View.GONE);
super.onPageFinished(view, url);
}
// WebView加载的所有资源url
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// view.loadData(errorHtml, "text/html; charset=UTF-8", null);
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
// 设置WebChromeClient
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public // 处理javascript中的alert
boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
return super.onJsAlert(view, url, message, result);
}
@Override
public // 处理javascript中的confirm
boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
return super.onJsConfirm(view, url, message, result);
}
@Override
public // 处理javascript中的prompt
boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
return super.onJsPrompt(view, url, message, defaultValue, result);
}
// 设置网页加载的进度条
@Override
public void onProgressChanged(WebView view, int newProgress) {
mProgressBar.setProgress(newProgress);
super.onProgressChanged(view, newProgress);
}
// 设置程序的Title
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
}
});
mWebView.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
// 表示按返回键
// 后退
mWebView.goBack();
// 已处理
return true;
}
}
return false;
}
});
}
use of android.webkit.WebChromeClient in project wechat by motianhuo.
the class WebViewActivity method initView.
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initView() {
Bundle bundle = getIntent().getExtras();
if (bundle != null && bundle.getString(Constants.URL) != null) {
strurl = "";
strurl = bundle.getString(Constants.URL);
}
if (bundle != null && bundle.getString(Constants.Title) != null) {
txt_title.setText(bundle.getString(Constants.Title));
}
if (!TextUtils.isEmpty(strurl)) {
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WeiboWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl(strurl);
}
}
use of android.webkit.WebChromeClient in project android_frameworks_base by DirtyUnicorns.
the class LooperAcceleration method makeView.
private View makeView() {
LinearLayout layout = new LinearLayout(this);
layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
if (INCLUDE_WEBVIEW) {
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient());
wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
return layout;
}
Aggregations