diff options
author | Mark Wei <markwei@google.com> | 2014-03-18 11:57:01 -0700 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2014-03-18 14:31:41 -0700 |
commit | 5b46c679794d2f4362e8064b0291c578835d75e0 (patch) | |
tree | d0669c69673422d39d7b0563869fbd46032c68a4 /src/com/android/bitmap/drawable/BasicBitmapDrawable.java | |
parent | 9f42e5cd4e26c6d3d175491c524763d1aefe8643 (diff) | |
download | bitmap-5b46c679794d2f4362e8064b0291c578835d75e0.tar.gz |
unbind() will not keep track of the previous key unless we specify that the
unbind is temporary. This prevents race conditions that cause an old key to be
bound on attach to window.
Bug: 13507371
Change-Id: I5187ddd956fe28472fde1ef11360840059d15423
Diffstat (limited to 'src/com/android/bitmap/drawable/BasicBitmapDrawable.java')
-rw-r--r-- | src/com/android/bitmap/drawable/BasicBitmapDrawable.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java index 831f410..42c4fbf 100644 --- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java +++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java @@ -135,6 +135,8 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback, * Binds to the given key and start the decode process. This will first look in the cache, then * decode from the request key if not found. * + * The key being replaced will be kept in {@link #mPrevKey}. + * * All UI operations should be called from the UI thread. */ public void bind(RequestKey key) { @@ -150,11 +152,28 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback, * Unbinds the current key and bitmap from the drawable. This will cause the bitmap to decrement * its ref count. * + * This will assume that you do not want to keep the unbound key in {@link #mPrevKey}. + * * All UI operations should be called from the UI thread. */ public void unbind() { + unbind(false); + } + + /** + * Unbinds the current key and bitmap from the drawable. This will cause the bitmap to decrement + * its ref count. + * + * If the temporary parameter is true, we will keep the unbound key in {@link #mPrevKey}. + * + * All UI operations should be called from the UI thread. + */ + public void unbind(boolean temporary) { Trace.beginSection("unbind"); setImage(null); + if (!temporary) { + mPrevKey = null; + } Trace.endSection(); } |