summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-11-21 00:58:33 -0800
committerMark Wei <markwei@google.com>2014-01-22 21:30:34 -0800
commit89e59f00d67791754e44e65413baa95f94056df4 (patch)
tree25c052346e9f118ed410eeffa58db0f104bbaf3b /src/com/android/bitmap/drawable/BasicBitmapDrawable.java
parent1ef4c6b7fdbc6e36c030e4a6fab3a8ccf8ba524b (diff)
downloadbitmap-89e59f00d67791754e44e65413baa95f94056df4.tar.gz
Decouple parallaxSpeedMultiplier from setDecodeDimensions().
Expose decode vertical center through ExtendedOptions. Genericize BitmapDrawableImageView#getTypedDrawable(). Bug: 11691744 Change-Id: I62e05ab2136cf031eaf1752dba728156c97c87a6
Diffstat (limited to 'src/com/android/bitmap/drawable/BasicBitmapDrawable.java')
-rw-r--r--src/com/android/bitmap/drawable/BasicBitmapDrawable.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
index 684d322..a09daad 100644
--- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
@@ -119,10 +119,12 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
*
* All UI operations should be called from the UI thread.
*/
- public final void setDecodeDimensions(int w, int h) {
- mDecodeWidth = w;
- mDecodeHeight = h;
- bind(mCurrKey);
+ public void setDecodeDimensions(int width, int height) {
+ if (mDecodeWidth == 0 || mDecodeHeight == 0) {
+ mDecodeWidth = width;
+ mDecodeHeight = height;
+ setImage(mCurrKey);
+ }
}
/**
@@ -133,6 +135,9 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
*/
public void bind(RequestKey key) {
Trace.beginSection("bind");
+ if (mCurrKey != null && mCurrKey.equals(key)) {
+ return;
+ }
setImage(key);
Trace.endSection();
}
@@ -153,10 +158,6 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
* Should only be overriden, not called.
*/
protected void setImage(final RequestKey key) {
- if (mCurrKey != null && mCurrKey.equals(key)) {
- return;
- }
-
Trace.beginSection("set image");
Trace.beginSection("release reference");
if (mBitmap != null) {
@@ -282,6 +283,10 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
return NO_MULTIPLIER;
}
+ /**
+ * Clients can override this to specify which section of the source image to decode from.
+ * Possible applications include using face detection to always decode around facial features.
+ */
protected float getDecodeVerticalCenter() {
return VERTICAL_CENTER;
}