aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout-land/download.xml2
-rw-r--r--res/layout-large-land/download.xml2
-rw-r--r--res/layout-port/download.xml2
-rw-r--r--res/layout/abstract_fragment_activity.xml2
-rw-r--r--res/layout/album_list_item.xml2
-rw-r--r--res/layout/chat_item.xml2
-rw-r--r--res/layout/chat_item_reverse.xml2
-rw-r--r--res/layout/select_album_header.xml2
-rw-r--r--res/layout/user_header.xml2
-rw-r--r--res/layout/user_list_item.xml2
-rw-r--r--src/github/daneren2005/dsub/view/RecyclingImageView.java57
-rw-r--r--src/github/daneren2005/dsub/view/SquareImageView.java2
12 files changed, 68 insertions, 11 deletions
diff --git a/res/layout-land/download.xml b/res/layout-land/download.xml
index e97db866..c0108597 100644
--- a/res/layout-land/download.xml
+++ b/res/layout-land/download.xml
@@ -21,7 +21,7 @@
android:layout_height="fill_parent"
android:layout_weight="1">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/download_album_art_image"
android:src="@drawable/unknown_album_large"
android:layout_width="wrap_content"
diff --git a/res/layout-large-land/download.xml b/res/layout-large-land/download.xml
index 18b560bc..139685e0 100644
--- a/res/layout-large-land/download.xml
+++ b/res/layout-large-land/download.xml
@@ -15,7 +15,7 @@
android:layout_height="0dip"
android:layout_weight="1">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/download_album_art_image"
android:src="@drawable/unknown_album_large"
android:layout_width="0dp"
diff --git a/res/layout-port/download.xml b/res/layout-port/download.xml
index b7d047c6..207ab260 100644
--- a/res/layout-port/download.xml
+++ b/res/layout-port/download.xml
@@ -29,7 +29,7 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/download_album_art_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/abstract_fragment_activity.xml b/res/layout/abstract_fragment_activity.xml
index 0268ff87..fae09e46 100644
--- a/res/layout/abstract_fragment_activity.xml
+++ b/res/layout/abstract_fragment_activity.xml
@@ -18,7 +18,7 @@
style="@style/BasicButton"
android:orientation="horizontal">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/album_art"
android:layout_width="50dip"
android:layout_height="50dip"
diff --git a/res/layout/album_list_item.xml b/res/layout/album_list_item.xml
index 202843b6..088cdcd3 100644
--- a/res/layout/album_list_item.xml
+++ b/res/layout/album_list_item.xml
@@ -9,7 +9,7 @@
android:layout_width="@dimen/AlbumArt.Small"
android:layout_height="@dimen/AlbumArt.Small">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/album_coverart"
android:layout_width="@dimen/AlbumArt.Small"
android:layout_height="@dimen/AlbumArt.Small"
diff --git a/res/layout/chat_item.xml b/res/layout/chat_item.xml
index b175d6c1..f31f7988 100644
--- a/res/layout/chat_item.xml
+++ b/res/layout/chat_item.xml
@@ -4,7 +4,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/chat_avatar"
android:src="@drawable/ic_social_person"
android:layout_width="@dimen/AlbumArt.Small"
diff --git a/res/layout/chat_item_reverse.xml b/res/layout/chat_item_reverse.xml
index 1d441da0..b8102193 100644
--- a/res/layout/chat_item_reverse.xml
+++ b/res/layout/chat_item_reverse.xml
@@ -52,7 +52,7 @@
android:layout_gravity="right"/>
</LinearLayout>
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/chat_avatar"
android:src="@drawable/ic_social_person"
android:layout_width="@dimen/AlbumArt.Small"
diff --git a/res/layout/select_album_header.xml b/res/layout/select_album_header.xml
index 19464103..f9eff4e8 100644
--- a/res/layout/select_album_header.xml
+++ b/res/layout/select_album_header.xml
@@ -100,7 +100,7 @@
android:layout_gravity="center_vertical"/>
</LinearLayout>
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/select_album_art"
android:layout_width="@dimen/AlbumArt.Header"
android:layout_height="@dimen/AlbumArt.Header"
diff --git a/res/layout/user_header.xml b/res/layout/user_header.xml
index 5966e0ed..0b303afe 100644
--- a/res/layout/user_header.xml
+++ b/res/layout/user_header.xml
@@ -4,7 +4,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/user_avatar"
android:src="@drawable/ic_social_person"
android:layout_width="wrap_content"
diff --git a/res/layout/user_list_item.xml b/res/layout/user_list_item.xml
index ac408295..146c44d5 100644
--- a/res/layout/user_list_item.xml
+++ b/res/layout/user_list_item.xml
@@ -5,7 +5,7 @@
android:layout_height="wrap_content"
android:background="@android:color/transparent">
- <ImageView
+ <github.daneren2005.dsub.view.RecyclingImageView
android:id="@+id/item_avatar"
android:src="@drawable/ic_social_person"
android:layout_width="@dimen/AlbumArt.Small"
diff --git a/src/github/daneren2005/dsub/view/RecyclingImageView.java b/src/github/daneren2005/dsub/view/RecyclingImageView.java
new file mode 100644
index 00000000..c4fc7f0a
--- /dev/null
+++ b/src/github/daneren2005/dsub/view/RecyclingImageView.java
@@ -0,0 +1,57 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2015 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.view;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+public class RecyclingImageView extends ImageView {
+ public RecyclingImageView(Context context) {
+ super(context);
+ }
+
+ public RecyclingImageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public RecyclingImageView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public RecyclingImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ Drawable drawable = this.getDrawable();
+ if(drawable != null && drawable instanceof BitmapDrawable) {
+ BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
+ if(bitmapDrawable.getBitmap() != null && bitmapDrawable.getBitmap().isRecycled()) {
+ this.setImageDrawable(null);
+ }
+ }
+
+ super.onDraw(canvas);
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/SquareImageView.java b/src/github/daneren2005/dsub/view/SquareImageView.java
index 77ca50db..44a74e16 100644
--- a/src/github/daneren2005/dsub/view/SquareImageView.java
+++ b/src/github/daneren2005/dsub/view/SquareImageView.java
@@ -19,7 +19,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
-public class SquareImageView extends ImageView {
+public class SquareImageView extends RecyclingImageView {
public SquareImageView(final Context context, final AttributeSet attrs) {
super(context, attrs);
}