diff options
author | Mark Wei <markwei@google.com> | 2013-11-21 00:58:33 -0800 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2014-01-22 21:30:34 -0800 |
commit | 89e59f00d67791754e44e65413baa95f94056df4 (patch) | |
tree | 25c052346e9f118ed410eeffa58db0f104bbaf3b /sample | |
parent | 1ef4c6b7fdbc6e36c030e4a6fab3a8ccf8ba524b (diff) | |
download | bitmap-89e59f00d67791754e44e65413baa95f94056df4.tar.gz |
Decouple parallaxSpeedMultiplier from setDecodeDimensions().
Expose decode vertical center through ExtendedOptions.
Genericize BitmapDrawableImageView#getTypedDrawable().
Bug: 11691744
Change-Id: I62e05ab2136cf031eaf1752dba728156c97c87a6
Diffstat (limited to 'sample')
-rw-r--r-- | sample/src/com/example/bitmapsample/BitmapView.java | 12 | ||||
-rw-r--r-- | sample/src/com/example/bitmapsample/MainActivity.java | 5 |
2 files changed, 5 insertions, 12 deletions
diff --git a/sample/src/com/example/bitmapsample/BitmapView.java b/sample/src/com/example/bitmapsample/BitmapView.java index 0613168..dc676dd 100644 --- a/sample/src/com/example/bitmapsample/BitmapView.java +++ b/sample/src/com/example/bitmapsample/BitmapView.java @@ -21,7 +21,6 @@ import android.graphics.Canvas; import android.util.AttributeSet; import android.widget.ListView; -import com.android.bitmap.drawable.BasicBitmapDrawable; import com.android.bitmap.drawable.ExtendedBitmapDrawable; import com.android.bitmap.view.BitmapDrawableImageView; @@ -29,7 +28,6 @@ public class BitmapView extends BitmapDrawableImageView { private final float mDensity; private ListView mListView; - private float mParallaxSpeedMultiplier; public BitmapView(Context c) { this(c, null); @@ -47,8 +45,8 @@ public class BitmapView extends BitmapDrawableImageView { @Override protected void onSizeChanged(final int w, final int h, int oldw, int oldh) { - ExtendedBitmapDrawable drawable = (ExtendedBitmapDrawable) getBasicBitmapDrawable(); - drawable.setDecodeDimensions(w, (int) (h * mParallaxSpeedMultiplier)); + ExtendedBitmapDrawable drawable = getTypedDrawable(); + drawable.setDecodeDimensions(w, h); } public void setListView(final ListView listView) { @@ -57,14 +55,10 @@ public class BitmapView extends BitmapDrawableImageView { @Override protected void onDraw(final Canvas canvas) { - ExtendedBitmapDrawable drawable = (ExtendedBitmapDrawable) getBasicBitmapDrawable(); + ExtendedBitmapDrawable drawable = getTypedDrawable(); float fraction = (float) getBottom() / (mListView.getHeight() + getHeight()); drawable.setParallaxFraction(fraction); super.onDraw(canvas); } - - public void setParallaxSpeedMultiplier(final float parallaxSpeedMultiplier) { - mParallaxSpeedMultiplier = parallaxSpeedMultiplier; - } }
\ No newline at end of file diff --git a/sample/src/com/example/bitmapsample/MainActivity.java b/sample/src/com/example/bitmapsample/MainActivity.java index cd8f6ac..5a2ac3a 100644 --- a/sample/src/com/example/bitmapsample/MainActivity.java +++ b/sample/src/com/example/bitmapsample/MainActivity.java @@ -118,11 +118,10 @@ public class MainActivity extends Activity { final ExtendedBitmapDrawable drawable = new ExtendedBitmapDrawable(getResources(), mCache, true /* limit density */, opts); - v.setBasicBitmapDrawable(drawable); + v.setTypedDrawable(drawable); v.setListView(mListView); - v.setParallaxSpeedMultiplier(NORMAL_PARALLAX_MULTIPLIER); } - v.getBasicBitmapDrawable().bind(new BitmapRequestKeyImpl(mItems[position])); + v.getTypedDrawable().bind(new BitmapRequestKeyImpl(mItems[position])); return v; } } |