public void init() {
webview = (WebView) context.findViewById(R.id.webviewer);
webview.setBackgroundColor(0xeeeeeeee);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setTextSize(TextSize.SMALLEST);
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setUserAgentString(
"Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
updateProgress(progress);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {
Toast.makeText(context, "Oh no! " + description,
Toast.LENGTH_SHORT).show();
hideProgress();
}
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("vnd.youtube")) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
return false;
}
}
});
}
public void load(String key) {
showProgress();
String url = URLBuilder.build(url_domain, "", key);
webview.loadUrl(url);
String title = webview.getTitle();
if (title != null) {
TextView tv = (TextView) context.findViewById(R.id.web_topic);
tv.setText(title);
}
currentTopic = key;
}