summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-11-05 00:39:06 -0800
committerMark Wei <markwei@google.com>2013-11-05 01:26:17 -0800
commit41af50eb1ac488572b066629c3954b23c21dfa76 (patch)
tree1749c63d05c174a27185eabae6cd2be71cfd3bf1
parent10dddd8a24a80d1d539997d8eaa9763c62bd02ad (diff)
downloadbitmap-41af50eb1ac488572b066629c3954b23c21dfa76.tar.gz
Change state from UNINITIALIZED to NOT_YET_LOADED earlier.
Relax restrictions on subclass. Change-Id: I456ed06e244de0ab794372b74094f9e94ed4b3f9
-rw-r--r--src/com/android/bitmap/drawable/BasicBitmapDrawable.java10
-rw-r--r--src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java11
2 files changed, 12 insertions, 9 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
index 7bb29a4..eaadf63 100644
--- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
@@ -62,6 +62,8 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
protected RequestKey mCurrKey;
protected RequestKey mPrevKey;
+ protected int mDecodeWidth;
+ protected int mDecodeHeight;
protected final Paint mPaint = new Paint();
private final BitmapCache mCache;
@@ -71,8 +73,6 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
private ReusableBitmap mBitmap;
private DecodeTask mTask;
private Cancelable mCreateFileDescriptorFactoryTask;
- private int mDecodeWidth;
- private int mDecodeHeight;
// based on framework CL:I015d77
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
@@ -109,7 +109,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
return mCurrKey;
}
- protected final ReusableBitmap getBitmap() {
+ protected ReusableBitmap getBitmap() {
return mBitmap;
}
@@ -131,7 +131,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
*
* All UI operations should be called from the UI thread.
*/
- public final void bind(RequestKey key) {
+ public void bind(RequestKey key) {
setImage(key);
}
@@ -141,7 +141,7 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
*
* All UI operations should be called from the UI thread.
*/
- public final void unbind() {
+ public void unbind() {
setImage(null);
}
diff --git a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
index fa3d071..e0ecd5e 100644
--- a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
@@ -34,7 +34,6 @@ import com.android.bitmap.DecodeAggregator;
import com.android.bitmap.DecodeTask;
import com.android.bitmap.R;
import com.android.bitmap.RequestKey;
-import com.android.bitmap.RequestKey.FileDescriptorFactory;
import com.android.bitmap.ReusableBitmap;
import com.android.bitmap.util.Trace;
@@ -151,13 +150,17 @@ public class ExtendedBitmapDrawable extends BasicBitmapDrawable implements
}
@Override
- protected void decode(final FileDescriptorFactory factory) {
+ protected void loadFileDescriptorFactory() {
boolean executeStateChange = shouldExecuteStateChange();
if (executeStateChange) {
- setLoadState(LOAD_STATE_NOT_YET_LOADED);
+ if (mCurrKey == null || mDecodeWidth == 0 || mDecodeHeight == 0) {
+ setLoadState(LOAD_STATE_FAILED);
+ } else {
+ setLoadState(LOAD_STATE_NOT_YET_LOADED);
+ }
}
- super.decode(factory);
+ super.loadFileDescriptorFactory();
}
protected boolean shouldExecuteStateChange() {