Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6a6539c authored by Adam Koch's avatar Adam Koch Committed by Android Git Automerger
Browse files

am e95c167c: Merge "Bitmapfun Sample: Minor updates/fixes." into klp-docs

* commit 'e95c167c':
  Bitmapfun Sample: Minor updates/fixes.
parents fe326adc e95c167c
Loading
Loading
Loading
Loading
+183 B (102 KiB)

File changed.

No diff preview for this file type.

+24 −21
Original line number Diff line number Diff line
@@ -160,13 +160,14 @@ a soft reference to the bitmap is placed
in a {@link java.util.HashSet}, for possible reuse later with
{@link android.graphics.BitmapFactory.Options#inBitmap}:

<pre>HashSet&lt;SoftReference&lt;Bitmap&gt;&gt; mReusableBitmaps;
<pre>Set&lt;SoftReference&lt;Bitmap&gt;&gt; mReusableBitmaps;
private LruCache&lt;String, BitmapDrawable&gt; mMemoryCache;

// If you're running on Honeycomb or newer, create
// a HashSet of references to reusable bitmaps.
// If you're running on Honeycomb or newer, create a
// synchronized HashSet of references to reusable bitmaps.
if (Utils.hasHoneycomb()) {
    mReusableBitmaps = new HashSet&lt;SoftReference&lt;Bitmap&gt;&gt;();
    mReusableBitmaps =
            Collections.synchronizedSet(new HashSet&lt;SoftReference&lt;Bitmap&gt;&gt;());
}

mMemoryCache = new LruCache&lt;String, BitmapDrawable&gt;(mCacheParams.memCacheSize) {
@@ -243,6 +244,7 @@ protected Bitmap getBitmapFromReusableSet(BitmapFactory.Options options) {
        Bitmap bitmap = null;

    if (mReusableBitmaps != null && !mReusableBitmaps.isEmpty()) {
        synchronized (mReusableBitmaps) {
            final Iterator&lt;SoftReference&lt;Bitmap&gt;&gt; iterator
                    = mReusableBitmaps.iterator();
            Bitmap item;
@@ -265,6 +267,7 @@ protected Bitmap getBitmapFromReusableSet(BitmapFactory.Options options) {
                }
            }
        }
    }
    return bitmap;
}</pre>