summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/view/BitmapDrawableImageView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/bitmap/view/BitmapDrawableImageView.java')
-rw-r--r--src/com/android/bitmap/view/BitmapDrawableImageView.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/com/android/bitmap/view/BitmapDrawableImageView.java b/src/com/android/bitmap/view/BitmapDrawableImageView.java
index b776c34..67ef3eb 100644
--- a/src/com/android/bitmap/view/BitmapDrawableImageView.java
+++ b/src/com/android/bitmap/view/BitmapDrawableImageView.java
@@ -47,18 +47,23 @@ public class BitmapDrawableImageView extends ImageView {
}
/**
- * Get the source BasicBitmapDrawable for this BitmapDrawableImageView.
- * @return The source drawable.
+ * Get the source drawable for this BitmapDrawableImageView.
+ * @return The source drawable casted to the given type, or null if the type does not match.
*/
- public BasicBitmapDrawable getBasicBitmapDrawable() {
- return mDrawable;
+ @SuppressWarnings("unchecked") // Cast to type parameter.
+ public <E extends BasicBitmapDrawable> E getTypedDrawable() {
+ try {
+ return (E) mDrawable;
+ } catch (Exception ignored) {
+ return null;
+ }
}
/**
- * Set the given BasicBitmapDrawable as the source for this BitmapDrawableImageView.
+ * Set the given drawable as the source for this BitmapDrawableImageView.
* @param drawable The source drawable.
*/
- public void setBasicBitmapDrawable(BasicBitmapDrawable drawable) {
+ public <E extends BasicBitmapDrawable> void setTypedDrawable(E drawable) {
super.setImageDrawable(drawable);
unbindDrawable();
mDrawable = drawable;