summaryrefslogtreecommitdiff
path: root/sample/src
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-10-22 16:57:01 -0700
committerMark Wei <markwei@google.com>2013-10-22 17:06:30 -0700
commita23358fbfd62c7aa1c84bfa8395b4dc427a71ce6 (patch)
tree5fe5ce44556e0d8dc267c168c6266651ff8a0222 /sample/src
parent333647f2886289a23a09a84365aa42d328ec54dc (diff)
downloadbitmap-a23358fbfd62c7aa1c84bfa8395b4dc427a71ce6.tar.gz
Add BasicImageView to unbind on detach for clients with long-lived caches.
Change visibility of mBitmap back to private. Expose through getter. Bug: 11337575 Change-Id: I511976388cc3b6962434416d9e7a632e6d8a1b72
Diffstat (limited to 'sample/src')
-rw-r--r--sample/src/com/example/bitmapsample/BitmapView.java26
-rw-r--r--sample/src/com/example/bitmapsample/MainActivity.java8
2 files changed, 8 insertions, 26 deletions
diff --git a/sample/src/com/example/bitmapsample/BitmapView.java b/sample/src/com/example/bitmapsample/BitmapView.java
index 37904f4..d8de0c9 100644
--- a/sample/src/com/example/bitmapsample/BitmapView.java
+++ b/sample/src/com/example/bitmapsample/BitmapView.java
@@ -17,15 +17,11 @@
package com.example.bitmapsample;
import android.content.Context;
-import android.os.Build;
import android.util.AttributeSet;
-import android.view.View;
-import com.android.bitmap.BitmapCache;
-import com.android.bitmap.drawable.BasicBitmapDrawable;
+import com.android.bitmap.view.BasicImageView;
-public class BitmapView extends View {
- private BasicBitmapDrawable mBitmapDrawable;
+public class BitmapView extends BasicImageView {
private float mDensity;
public BitmapView(Context c) {
@@ -44,22 +40,6 @@ public class BitmapView extends View {
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
- mBitmapDrawable.setDecodeDimensions(w, h);
+ getDrawable().setDecodeDimensions(w, h);
}
-
- public void setImage(String uriString) {
- if (mBitmapDrawable != null) {
- mBitmapDrawable.bind(new BitmapRequestKeyImpl(uriString));
- }
- }
-
- public void initialize(BitmapCache cache) {
- mBitmapDrawable = new BasicBitmapDrawable(getResources(), cache, true /* limitDensity */);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- setBackground(mBitmapDrawable);
- } else {
- setBackgroundDrawable(mBitmapDrawable);
- }
- }
-
} \ 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 6db2bc5..f580dd8 100644
--- a/sample/src/com/example/bitmapsample/MainActivity.java
+++ b/sample/src/com/example/bitmapsample/MainActivity.java
@@ -25,7 +25,7 @@ import android.widget.ListView;
import com.android.bitmap.BitmapCache;
import com.android.bitmap.UnrefedBitmapCache;
-import com.android.bitmap.util.Trace;
+import com.android.bitmap.drawable.BasicBitmapDrawable;
public class MainActivity extends Activity {
private ListView mListView;
@@ -91,9 +91,11 @@ public class MainActivity extends Activity {
v = (BitmapView) convertView;
} else {
v = new BitmapView(MainActivity.this);
- v.initialize(mCache);
+ final BasicBitmapDrawable drawable = new BasicBitmapDrawable(getResources(), mCache,
+ true /* limit density */);
+ v.setDrawable(drawable);
}
- v.setImage(mItems[position]);
+ v.getDrawable().bind(new BitmapRequestKeyImpl(mItems[position]));
return v;
}
}