summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-11-01 15:55:17 -0700
committerMark Wei <markwei@google.com>2013-11-04 10:57:01 -0800
commit5030ae34cd5978a8ab8a06f6c3b69b8645873122 (patch)
treef92417f29c823b422f868eb0c2ae0b9b357e4338 /sample
parent2e4d0863dba53435372ec96538f2ef3e1c3675bf (diff)
downloadbitmap-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')
-rw-r--r--sample/res/drawable-hdpi/ic_placeholder.pngbin725 -> 550 bytes
-rw-r--r--sample/res/drawable-mdpi/ic_placeholder.pngbin626 -> 481 bytes
-rw-r--r--sample/res/drawable-xhdpi/ic_placeholder.pngbin840 -> 681 bytes
-rw-r--r--sample/res/drawable-xxhdpi/ic_placeholder.pngbin1382 -> 588 bytes
-rw-r--r--sample/src/com/example/bitmapsample/BitmapRequestKeyImpl.java2
-rw-r--r--sample/src/com/example/bitmapsample/MainActivity.java13
6 files changed, 11 insertions, 4 deletions
diff --git a/sample/res/drawable-hdpi/ic_placeholder.png b/sample/res/drawable-hdpi/ic_placeholder.png
index 7b05b48..9e20328 100644
--- a/sample/res/drawable-hdpi/ic_placeholder.png
+++ b/sample/res/drawable-hdpi/ic_placeholder.png
Binary files differ
diff --git a/sample/res/drawable-mdpi/ic_placeholder.png b/sample/res/drawable-mdpi/ic_placeholder.png
index 752149d..339c316 100644
--- a/sample/res/drawable-mdpi/ic_placeholder.png
+++ b/sample/res/drawable-mdpi/ic_placeholder.png
Binary files differ
diff --git a/sample/res/drawable-xhdpi/ic_placeholder.png b/sample/res/drawable-xhdpi/ic_placeholder.png
index 92ed99b..ca79f26 100644
--- a/sample/res/drawable-xhdpi/ic_placeholder.png
+++ b/sample/res/drawable-xhdpi/ic_placeholder.png
Binary files differ
diff --git a/sample/res/drawable-xxhdpi/ic_placeholder.png b/sample/res/drawable-xxhdpi/ic_placeholder.png
index 18ac128..c2c2877 100644
--- a/sample/res/drawable-xxhdpi/ic_placeholder.png
+++ b/sample/res/drawable-xxhdpi/ic_placeholder.png
Binary files differ
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);