Loading packages/DocumentsUI/src/com/android/documentsui/ThumbnailCache.java +7 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentCallbacks2; import android.graphics.Bitmap; import android.graphics.Point; import android.net.Uri; import android.os.Looper; import android.util.LruCache; import android.util.Pair; import android.util.Pools; Loading Loading @@ -195,6 +196,9 @@ public class ThumbnailCache { private static Result obtain(@Status int status, @Nullable Bitmap thumbnail, @Nullable Point size, long lastModified) { // Make sure this method is only called from main thread. assert(Looper.myLooper() == Looper.getMainLooper()); Result instance = sPool.acquire(); instance = (instance != null ? instance : new Result()); Loading @@ -209,6 +213,9 @@ public class ThumbnailCache { private Result() {} public void recycle() { // Make sure this method is only called from main thread. assert(Looper.myLooper() == Looper.getMainLooper()); mStatus = -1; mThumbnail = null; mSize = null; Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/IconHelper.java +21 −17 Original line number Diff line number Diff line Loading @@ -258,11 +258,13 @@ public class IconHelper { ImageView iconThumb, ImageView iconMime) { final Result result = mThumbnailCache.getThumbnail(uri, mCurrentSize); try { final Bitmap cachedThumbnail = result.getThumbnail(); iconThumb.setImageBitmap(cachedThumbnail); boolean stale = (docLastModified > result.getLastModified()); if (DEBUG) Log.d(TAG, String.format("Load thumbnail for %s, got result %d and stale %b.", if (DEBUG) Log.d(TAG, String.format("Load thumbnail for %s, got result %d and stale %b.", uri.toString(), result.getStatus(), stale)); if (!result.isExactHit() || stale) { final BiConsumer<View, View> animator = Loading @@ -274,9 +276,11 @@ public class IconHelper { ProviderExecutor.forAuthority(docAuthority).execute(task); } result.recycle(); return result.isHit(); } finally { result.recycle(); } } private void setMimeIcon(ImageView view, Drawable icon) { Loading Loading
packages/DocumentsUI/src/com/android/documentsui/ThumbnailCache.java +7 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ComponentCallbacks2; import android.graphics.Bitmap; import android.graphics.Point; import android.net.Uri; import android.os.Looper; import android.util.LruCache; import android.util.Pair; import android.util.Pools; Loading Loading @@ -195,6 +196,9 @@ public class ThumbnailCache { private static Result obtain(@Status int status, @Nullable Bitmap thumbnail, @Nullable Point size, long lastModified) { // Make sure this method is only called from main thread. assert(Looper.myLooper() == Looper.getMainLooper()); Result instance = sPool.acquire(); instance = (instance != null ? instance : new Result()); Loading @@ -209,6 +213,9 @@ public class ThumbnailCache { private Result() {} public void recycle() { // Make sure this method is only called from main thread. assert(Looper.myLooper() == Looper.getMainLooper()); mStatus = -1; mThumbnail = null; mSize = null; Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/IconHelper.java +21 −17 Original line number Diff line number Diff line Loading @@ -258,11 +258,13 @@ public class IconHelper { ImageView iconThumb, ImageView iconMime) { final Result result = mThumbnailCache.getThumbnail(uri, mCurrentSize); try { final Bitmap cachedThumbnail = result.getThumbnail(); iconThumb.setImageBitmap(cachedThumbnail); boolean stale = (docLastModified > result.getLastModified()); if (DEBUG) Log.d(TAG, String.format("Load thumbnail for %s, got result %d and stale %b.", if (DEBUG) Log.d(TAG, String.format("Load thumbnail for %s, got result %d and stale %b.", uri.toString(), result.getStatus(), stale)); if (!result.isExactHit() || stale) { final BiConsumer<View, View> animator = Loading @@ -274,9 +276,11 @@ public class IconHelper { ProviderExecutor.forAuthority(docAuthority).execute(task); } result.recycle(); return result.isHit(); } finally { result.recycle(); } } private void setMimeIcon(ImageView view, Drawable icon) { Loading