private void updateViews() { if (mTitle != null) { // Link the title to the entry URL SpannableString link = new SpannableString(mTitle); if (mUrl != null) { int start = 0; int end = mTitle.length(); int flags = 0; link.setSpan(new URLSpan(mUrl), start, end, flags); } mTitleView.setText(link); // Show the content, or the summary if no content is available. String body = !TextUtils.isEmpty(mContent) ? mContent : !TextUtils.isEmpty(mSummary) ? mSummary : ""; // Show the feed title in the window decorator. if (!TextUtils.isEmpty(mTitle)) { setTitle(mTitle); } else { Context context = getContext(); setTitle(context.getText(R.string.atom_title_entry)); } // Use loadDataWithBaseURL instead of loadData for unsanitized HTML: // http://code.google.com/p/android/issues/detail?id=1733 mContentView.clearView(); mContentView.loadDataWithBaseURL(null, body, MIME_TYPE, ENCODING, null); } }
public void refresh() { webView.clearView(); webView.loadUrl("about:blank"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_action_view, null); Animation rotation = AnimationUtils.loadAnimation(this, R.anim.refresh); iv.startAnimation(rotation); refreshItem.setActionView(iv); webView.loadUrl(getWeiboOAuthUrl()); }
protected void loadWebViewData(String content) { if (Build.VERSION.SDK_INT < 18) { descriptionView.clearView(); } else { descriptionView.loadUrl("about:blank"); } // webview bug android versions 2.3.X // http://stackoverflow.com/a/8162828/1484047 if ("2.3".equals(Build.VERSION.RELEASE)) { descriptionView.loadDataWithBaseURL(null, content, "text/html; charset=utf-8", "utf-8", null); } else { myWebViewClient.setContent(content); descriptionView.loadUrl("file:///android_asset/integreat.html"); // descriptionView.loadData(content, "text/html; charset=utf-8", "utf-8"); } }
/** 退出系统 * */ private void exit() { contentWebView.loadUrl("about:blank"); // Activity专用的推退出 // webView.clearCache(true); contentWebView.clearView(); // webView.clearHistory(); contentWebView.destroy(); toolbarWebView.clearHistory(); finish(); // 通过结束进程 android.os.Process.killProcess(android.os.Process.myPid()); // 通过Activity自带的ActivityService来结束应用程序 系统会将,该包下的 // ,所有进程,服务,全部杀掉,就可以杀干净了 ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); am.restartPackage(getPackageName()); // 系统级别的退出 其中传递的状态码 表示退出的级别 System.exit(-1); }
@Test public void shouldRecordClearView() { assertThat(shadowWebView.wasClearViewCalled()).isFalse(); webView.clearView(); assertThat(shadowWebView.wasClearViewCalled()).isTrue(); }