diff options
author | Mark Wei <markwei@google.com> | 2013-11-01 15:55:17 -0700 |
---|---|---|
committer | Mark Wei <markwei@google.com> | 2013-11-04 10:57:01 -0800 |
commit | 5030ae34cd5978a8ab8a06f6c3b69b8645873122 (patch) | |
tree | f92417f29c823b422f868eb0c2ae0b9b357e4338 /sample/src | |
parent | 2e4d0863dba53435372ec96538f2ef3e1c3675bf (diff) | |
download | bitmap-5030ae34cd5978a8ab8a06f6c3b69b8645873122.tar.gz |
Modify ExtendedBitmapDrawable to be more flexible for clients.
Introducing ExtendedOptions:
Clients can now specify the features they want out of a ExtendedBitmapDrawable:
1) Ordered display (decode aggregator)
2) Parallax
3) State changes (placeholder and/or progress bar)
Clients can also specify parameters to those features. These parameters can be
modified and changes take effect immediately.
Change-Id: I15e4f1dbc20473db6798888b07b4bd34c712db21
Diffstat (limited to 'sample/src')
-rw-r--r-- | sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java | 2 | ||||
-rw-r--r-- | sample/src/com/example/bitmapsample/MainActivity.java | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java b/sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java index eeec78f..dd1696c 100644 --- a/sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java +++ b/sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java @@ -78,7 +78,7 @@ public class BitmapRequestKeyImpl implements RequestKey { // Character difference between shortest and longest uri. final long spread = 26; // Maximum amount of time to sleep. - final long max = 2; + final long max = 3; final long duration = (long) ((float) (mUriString.length() % spread) / spread * max * 1000); try { diff --git a/sample/src/com/example/bitmapsample/MainActivity.java b/sample/src/com/example/bitmapsample/MainActivity.java index 96e99ec..cd8f6ac 100644 --- a/sample/src/com/example/bitmapsample/MainActivity.java +++ b/sample/src/com/example/bitmapsample/MainActivity.java @@ -18,6 +18,7 @@ package com.example.bitmapsample; import android.app.Activity; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; @@ -29,11 +30,12 @@ import com.android.bitmap.BitmapCache; import com.android.bitmap.DecodeAggregator; import com.android.bitmap.UnrefedBitmapCache; import com.android.bitmap.drawable.ExtendedBitmapDrawable; +import com.android.bitmap.drawable.ExtendedBitmapDrawable.ExtendedOptions; public class MainActivity extends Activity { private ListView mListView; - private final BitmapCache mCache = new UnrefedBitmapCache(TARGET_CACHE_SIZE_BYTES, 0.1f, 0); + private final BitmapCache mCache = new UnrefedBitmapCache(TARGET_CACHE_SIZE_BYTES, 0, 0); private final DecodeAggregator mDecodeAggregator = new DecodeAggregator(); private static Drawable PLACEHOLDER; @@ -107,9 +109,14 @@ public class MainActivity extends Activity { v = (BitmapView) convertView; } else { v = new BitmapView(MainActivity.this); + ExtendedOptions opts = new ExtendedOptions( + ExtendedOptions.FEATURE_ORDERED_DISPLAY | ExtendedOptions.FEATURE_PARALLAX + | ExtendedOptions.FEATURE_STATE_CHANGES, PLACEHOLDER, PROGRESS); + opts.decodeAggregator = mDecodeAggregator; + opts.parallaxSpeedMultiplier = NORMAL_PARALLAX_MULTIPLIER; + opts.backgroundColor = Color.LTGRAY; final ExtendedBitmapDrawable drawable = new ExtendedBitmapDrawable(getResources(), - mCache, true /* limit density */, mDecodeAggregator, PLACEHOLDER, PROGRESS); - drawable.setParallaxSpeedMultiplier(NORMAL_PARALLAX_MULTIPLIER); + mCache, true /* limit density */, opts); v.setBasicBitmapDrawable(drawable); v.setListView(mListView); |