Example usage for android.view View DRAWING_CACHE_QUALITY_LOW

List of usage examples for android.view View DRAWING_CACHE_QUALITY_LOW

Introduction

In this page you can find the example usage for android.view View DRAWING_CACHE_QUALITY_LOW.

Prototype

int DRAWING_CACHE_QUALITY_LOW

To view the source code for android.view View DRAWING_CACHE_QUALITY_LOW.

Click Source Link

Document

Enables low quality mode for the drawing cache.

Usage

From source file:Main.java

/**
 * Convert a view to a bitmap./*from w w  w .jav  a2  s.c o  m*/
 *
 * @param view the view to convert
 * @return the converted bitmap
 */
public static Bitmap createBitmapFromView(@NonNull View view) {
    view.setDrawingCacheEnabled(true);
    view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
    view.buildDrawingCache();

    if (view.getDrawingCache() == null) {
        return null;
    }

    Bitmap snapshot = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);
    view.destroyDrawingCache();
    return snapshot;
}

From source file:org.mariotaku.twidere.util.SwipebackActivityUtils.java

public static void setActivityScreenshot(final Activity activity, final Intent target) {
    if (activity == null || target == null)
        return;/*  ww  w.j  ava  2  s .  c  o  m*/
    final SharedPreferences prefs = activity.getSharedPreferences(SHARED_PREFERENCES_NAME,
            Context.MODE_PRIVATE);
    if (!prefs.getBoolean(KEY_SWIPE_BACK, false))
        return;
    final TwidereApplication app = TwidereApplication.getInstance(activity);
    final SwipebackScreenshotManager sm = app.getSwipebackScreenshotManager();
    final long key = System.currentTimeMillis();
    final Bitmap sc = getActivityScreenshot(activity, View.DRAWING_CACHE_QUALITY_LOW);
    sm.put(key, sc, ThemeUtils.isTransparentBackground(activity));
    target.putExtra(EXTRA_ACTIVITY_SCREENSHOT_ID, key);
}

From source file:de.vanita5.twittnuker.util.SwipebackActivityUtils.java

public static void setActivityScreenshot(final Activity activity, final Intent target) {
    if (activity == null || target == null)
        return;//from w  w w . j  av  a  2  s  .  c  o m
    final SharedPreferences prefs = activity.getSharedPreferences(SHARED_PREFERENCES_NAME,
            Context.MODE_PRIVATE);
    if (!prefs.getBoolean(KEY_SWIPE_BACK, true))
        return;
    final TwittnukerApplication app = TwittnukerApplication.getInstance(activity);
    final SwipebackScreenshotManager sm = app.getSwipebackScreenshotManager();
    final long key = System.currentTimeMillis();
    final Bitmap sc = getActivityScreenshot(activity, View.DRAWING_CACHE_QUALITY_LOW);
    sm.put(key, sc, ThemeUtils.isTransparentBackground(activity));
    target.putExtra(EXTRA_ACTIVITY_SCREENSHOT_ID, key);
}