summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/view
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-10-24 14:51:54 -0700
committerMark Wei <markwei@google.com>2013-10-29 20:22:10 -0700
commit9c6ac19d4a3d39b7c2992060957920118ff56a65 (patch)
tree7ee9bd8104520b791f101c4e037795e16e3ec30c /src/com/android/bitmap/view
parent46616414f6dabb6d57b0ac433a5fabe2abb8b5a9 (diff)
downloadbitmap-9c6ac19d4a3d39b7c2992060957920118ff56a65.tar.gz
Relax BasicBitmapView to allow non-BasicBitmapDrawables to be assigned to it.
Rename BasicBitmapView to BitmapDrawableImageView. Allow asynchronous creating of file. Change-Id: I0407bf0bf36ae92ce45d2175121a15483f8f72f2
Diffstat (limited to 'src/com/android/bitmap/view')
-rw-r--r--src/com/android/bitmap/view/BitmapDrawableImageView.java (renamed from src/com/android/bitmap/view/BasicImageView.java)67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/com/android/bitmap/view/BasicImageView.java b/src/com/android/bitmap/view/BitmapDrawableImageView.java
index 3e48af5..a55b864 100644
--- a/src/com/android/bitmap/view/BasicImageView.java
+++ b/src/com/android/bitmap/view/BitmapDrawableImageView.java
@@ -27,68 +27,77 @@ import com.android.bitmap.drawable.BasicBitmapDrawable;
/**
* A helpful ImageView replacement that can generally be used in lieu of ImageView.
- * BasicImageView has logic to unbind its BasicBitmapDrawable when it is detached from the window.
+ * BitmapDrawableImageView has logic to unbind its BasicBitmapDrawable when it is detached from the
+ * window.
*/
-public class BasicImageView extends ImageView {
+public class BitmapDrawableImageView extends ImageView {
private BasicBitmapDrawable mDrawable;
- public BasicImageView(final Context context) {
+ public BitmapDrawableImageView(final Context context) {
this(context, null);
}
- public BasicImageView(final Context context, final AttributeSet attrs) {
+ public BitmapDrawableImageView(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
- public BasicImageView(final Context context, final AttributeSet attrs, final int defStyle) {
+ public BitmapDrawableImageView(final Context context, final AttributeSet attrs,
+ final int defStyle) {
super(context, attrs, defStyle);
}
/**
- * Set the given BasicBitmapDrawable as the source for this BasicImageView.
+ * Get the source BasicBitmapDrawable for this BitmapDrawableImageView.
+ * @return The source drawable.
+ */
+ public BasicBitmapDrawable getBasicBitmapDrawable() {
+ return mDrawable;
+ }
+
+ /**
+ * Set the given BasicBitmapDrawable as the source for this BitmapDrawableImageView.
* @param drawable The source drawable.
*/
- public void setDrawable(BasicBitmapDrawable drawable) {
+ public void setBasicBitmapDrawable(BasicBitmapDrawable drawable) {
super.setImageDrawable(drawable);
+ unbindDrawable();
mDrawable = drawable;
}
- public BasicBitmapDrawable getDrawable() {
- return mDrawable;
+ private void unbindDrawable() {
+ if (mDrawable != null) {
+ mDrawable.unbind();
+ mDrawable = null;
+ }
}
@Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
-
- mDrawable.unbind();
+ public void setImageResource(final int resId) {
+ super.setImageResource(resId);
+ unbindDrawable();
}
@Override
- public void setImageDrawable(final Drawable drawable) {
- throw new UnsupportedOperationException(
- "BasicImageView is only compatible with BasicBitmapDrawable. Use setDrawable() "
- + "instead.");
+ public void setImageURI(final Uri uri) {
+ super.setImageURI(uri);
+ unbindDrawable();
}
@Override
- public void setImageResource(final int resId) {
- throw new UnsupportedOperationException(
- "BasicImageView is only compatible with BasicBitmapDrawable. Use setDrawable() "
- + "instead.");
+ public void setImageDrawable(final Drawable drawable) {
+ super.setImageDrawable(drawable);
+ unbindDrawable();
}
@Override
- public void setImageURI(final Uri uri) {
- throw new UnsupportedOperationException(
- "BasicImageView is only compatible with BasicBitmapDrawable. Use setDrawable() "
- + "instead.");
+ public void setImageBitmap(final Bitmap bm) {
+ super.setImageBitmap(bm);
+ unbindDrawable();
}
@Override
- public void setImageBitmap(final Bitmap bm) {
- throw new UnsupportedOperationException(
- "BasicImageView is only compatible with BasicBitmapDrawable. Use setDrawable() "
- + "instead.");
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ unbindDrawable();
}
}