Java Code Examples for android.view.View.setDrawingCacheQuality()

The following are Jave code examples for showing how to use setDrawingCacheQuality() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: BlurTask.java   Source Code and License Vote up 6 votes
public BlurTask(View target, BlurFactor factor, Callback callback) {
  target.setDrawingCacheEnabled(true);
  this.res = target.getResources();
  this.factor = factor;
  this.callback = callback;

  target.destroyDrawingCache();
  target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  capture = target.getDrawingCache();
  contextWeakRef = new WeakReference<>(target.getContext());
}
 
Example 2
Project: BBSSDK-for-Android   File: BlurTask.java   Source Code and License Vote up 6 votes
public BlurTask(View target, BlurFactor factor, Callback callback) {
	this.res = target.getResources();
	this.factor = factor;
	this.callback = callback;
	this.contextWeakRef = new WeakReference<Context>(target.getContext());

	target.setDrawingCacheEnabled(true);
	target.destroyDrawingCache();
	target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
	bitmap = target.getDrawingCache();
}
 
Example 3
Project: QiangHongBao   File: BlurTask.java   Source Code and License Vote up 6 votes
public BlurTask(View target, BlurFactor factor, Callback callback) {
  this.res = target.getResources();
  this.factor = factor;
  this.callback = callback;
  this.contextWeakRef = new WeakReference<>(target.getContext());

  target.setDrawingCacheEnabled(true);
  target.destroyDrawingCache();
  target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  bitmap = target.getDrawingCache();
}
 
Example 4
Project: container   File: RemoteViewsUtils.java   Source Code and License Vote up 6 votes
public Bitmap createBitmap(final Context context, RemoteViews remoteViews, boolean isBig, boolean systemId) {
	View mCache = null;
	try {
		mCache = createView(context, remoteViews, isBig, systemId);
	} catch (Throwable throwable) {
		try {
			// apply失败后,根据布局id创建view
			mCache = LayoutInflater.from(context).inflate(remoteViews.getLayoutId(), null);
		} catch (Throwable e) {

		}
	}
	if (mCache == null) {
		return null;
	}
	mCache.setDrawingCacheEnabled(true);
	mCache.buildDrawingCache();
	mCache.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
	return mCache.getDrawingCache();
}
 
Example 5
Project: GitHub   File: Blur.java   Source Code and License Vote up 5 votes
public static Bitmap of(View view, BlurFactor factor) {
  view.setDrawingCacheEnabled(true);
  view.destroyDrawingCache();
  view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  Bitmap cache = view.getDrawingCache();
  Bitmap bitmap = of(view.getContext(), cache, factor);
  cache.recycle();
  return bitmap;
}
 
Example 6
Project: BBSSDK-for-Android   File: Blur.java   Source Code and License Vote up 5 votes
public static Bitmap of(View view, BlurFactor factor) {
	view.setDrawingCacheEnabled(true);
	view.destroyDrawingCache();
	view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
	Bitmap cache = view.getDrawingCache();
	Bitmap bitmap = of(view.getContext(), cache, factor);
	cache.recycle();
	return bitmap;
}
 
Example 7
Project: KTools   File: ImageActivity.java   Source Code and License Vote up 5 votes
@OnClick(R.id.btn_screen_capture)
public void onBtnScreenCaptureClicked() {
    View decorView = getWindow().getDecorView();
    decorView.setDrawingCacheEnabled(true);
    decorView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    decorView.buildDrawingCache();
    Bitmap screen = Bitmap.createBitmap(decorView.getDrawingCache());
    KDialog.showImgInDialog(this, screen);
}
 
Example 8
Project: QiangHongBao   File: Blur.java   Source Code and License Vote up 5 votes
public static Bitmap of(View view, BlurFactor factor) {
  view.setDrawingCacheEnabled(true);
  view.destroyDrawingCache();
  view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  Bitmap cache = view.getDrawingCache();
  Bitmap bitmap = of(view.getContext(), cache, factor);
  cache.recycle();
  return bitmap;
}
 
Example 9
Project: Accessibility   File: BitmapUtils.java   Source Code and License Vote up 4 votes
private static Bitmap getBitmapFromView(View view, int tryTime, boolean forceHighQuality) {
    boolean willNotCacheDrawingBefore = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);

    int drawingCacheBackgroundColorBefore = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(0);
    int drawingCacheQualityBefore = view.getDrawingCacheQuality();
    if (drawingCacheBackgroundColorBefore != 0) {
        view.destroyDrawingCache();
    }
    if (tryTime > 1) {
        view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null || cacheBitmap.isRecycled()) {
        view.setDrawingCacheQuality(drawingCacheQualityBefore);
        view.setWillNotCacheDrawing(willNotCacheDrawingBefore);
        view.setDrawingCacheBackgroundColor(drawingCacheBackgroundColorBefore);

        if (tryTime < TRY_GET_BITMAP_FROM_VIEW_MAX_REPEAT_TIME) {
            handleOutOfMemory();
            return getBitmapFromView(view, tryTime + 1, forceHighQuality);
        }
        return null;
    }

    Bitmap bitmap = createBitmap(cacheBitmap, cacheBitmap.getWidth(), cacheBitmap.getHeight(), forceHighQuality || tryTime == 1 ? Config.ARGB_8888
            : Config.ARGB_4444);

    if (bitmap == cacheBitmap) {
        bitmap = createBitmap(cacheBitmap);
    }

    view.destroyDrawingCache();

    view.setDrawingCacheQuality(drawingCacheQualityBefore);
    view.setWillNotCacheDrawing(willNotCacheDrawingBefore);
    view.setDrawingCacheBackgroundColor(drawingCacheBackgroundColorBefore);

    return bitmap;
}