summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/drawable
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-10-22 16:57:01 -0700
committerMark Wei <markwei@google.com>2013-10-22 17:06:30 -0700
commita23358fbfd62c7aa1c84bfa8395b4dc427a71ce6 (patch)
tree5fe5ce44556e0d8dc267c168c6266651ff8a0222 /src/com/android/bitmap/drawable
parent333647f2886289a23a09a84365aa42d328ec54dc (diff)
downloadbitmap-a23358fbfd62c7aa1c84bfa8395b4dc427a71ce6.tar.gz
Add BasicImageView to unbind on detach for clients with long-lived caches.
Change visibility of mBitmap back to private. Expose through getter. Bug: 11337575 Change-Id: I511976388cc3b6962434416d9e7a632e6d8a1b72
Diffstat (limited to 'src/com/android/bitmap/drawable')
-rw-r--r--src/com/android/bitmap/drawable/BasicBitmapDrawable.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
index 9cee3c0..b172373 100644
--- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
@@ -34,6 +34,7 @@ import com.android.bitmap.ReusableBitmap;
import com.android.bitmap.util.BitmapUtils;
import com.android.bitmap.util.RectUtils;
import com.android.bitmap.util.Trace;
+import com.android.bitmap.view.BasicImageView;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
@@ -45,18 +46,23 @@ import java.util.concurrent.TimeUnit;
* including request creation/cancelling, and data unbinding and re-binding.
* <p>
* The actual bitmap decode work is handled by {@link DecodeTask}.
+ * <p>
+ * If being used with a long-lived cache (static cache, attached to the Application instead of the
+ * Activity, etc) then make sure to call {@link BasicBitmapDrawable#unbind()} at the appropriate
+ * times so the cache has accurate unref counts. The {@link BasicImageView} class has been created
+ * to do the appropriate unbind operation when the view is detached from the window.
*/
public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCallback,
Drawable.Callback {
protected static Rect sRect;
protected RequestKey mCurrKey;
- protected ReusableBitmap mBitmap;
protected final Paint mPaint = new Paint();
private final BitmapCache mCache;
private final boolean mLimitDensity;
private final float mDensity;
+ private ReusableBitmap mBitmap;
private DecodeTask mTask;
private int mDecodeWidth;
private int mDecodeHeight;
@@ -229,6 +235,10 @@ public class BasicBitmapDrawable extends Drawable implements DecodeTask.DecodeCa
@Override
public void onDecodeCancel(final RequestKey key) { }
+ protected ReusableBitmap getBitmap() {
+ return mBitmap;
+ }
+
private void setBitmap(ReusableBitmap bmp) {
if (mBitmap != null && mBitmap != bmp) {
mBitmap.releaseReference();