android.webkit.WebView.destroyDrawingCache()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(264)

本文整理了Java中android.webkit.WebView.destroyDrawingCache()方法的一些代码示例,展示了WebView.destroyDrawingCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.destroyDrawingCache()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:destroyDrawingCache

WebView.destroyDrawingCache介绍

暂无

代码示例

代码示例来源:origin: airbnb/AirMapView

@Override public void getSnapshot(OnSnapshotReadyListener listener) {
  boolean isDrawingCacheEnabled = webView.isDrawingCacheEnabled();
  webView.setDrawingCacheEnabled(true);
  // copy to a new bitmap, otherwise the bitmap will be
  // destroyed when the drawing cache is destroyed
  // webView.getDrawingCache can return null if drawing cache is disabled or if the size is 0
  Bitmap bitmap = webView.getDrawingCache();
  Bitmap newBitmap = null;
  if (bitmap != null) {
   newBitmap = bitmap.copy(Bitmap.Config.RGB_565, false);
  }

  webView.destroyDrawingCache();
  webView.setDrawingCacheEnabled(isDrawingCacheEnabled);

  listener.onSnapshotReady(newBitmap);
 }
}

代码示例来源:origin: LonamiWebs/Stringlate

/**
 * Create a picture out of {@link WebView}'s whole content
 *
 * @param webView The WebView to get contents from
 * @return A {@link Bitmap} or null
 */
@Nullable
public static Bitmap getBitmapFromWebView(WebView webView) {
  try {
    //Measure WebView's content
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    webView.measure(widthMeasureSpec, heightMeasureSpec);
    webView.layout(0, 0, webView.getMeasuredWidth(), webView.getMeasuredHeight());
    //Build drawing cache and store its size
    webView.buildDrawingCache();
    int measuredWidth = webView.getMeasuredWidth();
    int measuredHeight = webView.getMeasuredHeight();
    //Creates the bitmap and draw WebView's content on in
    Bitmap bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(bitmap, 0, bitmap.getHeight(), new Paint());
    webView.draw(canvas);
    webView.destroyDrawingCache();
    return bitmap;
  } catch (Exception | OutOfMemoryError e) {
    e.printStackTrace();
    return null;
  }
}

代码示例来源:origin: hezhubo/HPlayer

@Override
public void onDestroy() {
  mWebView.stopLoading();
  mWebView.destroyDrawingCache();
  mWebView.removeAllViews();
  mWebView.setVisibility(View.GONE);
  mWebView.destroy();
  super.onDestroy();
}

代码示例来源:origin: devinhu/androidone

webview.setWebChromeClient(null);
webview.setWebViewClient(null);
webview.destroyDrawingCache();
webview.destroy();
webview = null;

代码示例来源:origin: youxin11544/RxJava_Simple

webview.setWebChromeClient(null);
webview.setWebViewClient(null);
webview.destroyDrawingCache();
webview.destroy();
webview = null;

代码示例来源:origin: bitstadium/HockeySDK-Android

webView.destroyDrawingCache();
webView.loadDataWithBaseURL(Constants.BASE_URL, versionHelper.getReleaseNotes(false), "text/html", "utf-8", null);

相关文章

WebView类方法