diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-07 19:17:14 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-07 19:17:14 -0800 |
commit | 3f5a1d0c2707f8318e42bc109b7d5df2e8c401eb (patch) | |
tree | f47a4ee8255ff021113e456dd48d30af1ad2b7cb /subsonic-android/src | |
parent | f3c0b10b05bad7827881cecd48c2567eb72c3b1d (diff) | |
download | dsub-3f5a1d0c2707f8318e42bc109b7d5df2e8c401eb.tar.gz dsub-3f5a1d0c2707f8318e42bc109b7d5df2e8c401eb.tar.bz2 dsub-3f5a1d0c2707f8318e42bc109b7d5df2e8c401eb.zip |
Only keep one ImageLoader in memory
Diffstat (limited to 'subsonic-android/src')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java | 6 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java index a6430569..cc986d2d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java @@ -311,6 +311,12 @@ public class SubsonicTabActivity extends SherlockActivity { }
return IMAGE_LOADER;
}
+ public synchronized static ImageLoader getStaticImageLoader(Context context) {
+ if (IMAGE_LOADER == null) {
+ IMAGE_LOADER = new ImageLoader(context);
+ }
+ return IMAGE_LOADER;
+ }
protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background) {
downloadRecursively(id, "", true, save, append, autoplay, shuffle, background);
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/subsonic-android/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java index c554b35b..e6528d1b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java @@ -10,6 +10,7 @@ import android.content.Intent; import android.media.AudioManager; import android.media.MediaMetadataRetriever; import android.media.RemoteControlClient; +import github.daneren2005.dsub.activity.SubsonicTabActivity; @TargetApi(14) public class RemoteControlClientICS extends RemoteControlClientHelper { @@ -39,7 +40,7 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP); - imageLoader = new ImageLoader(context); + imageLoader = SubsonicTabActivity.getStaticImageLoader(context); } public void unregister(final Context context) { @@ -54,6 +55,10 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { } public void updateMetadata(final Context context, final MusicDirectory.Entry currentSong) { + if(imageLoader == null) { + imageLoader = SubsonicTabActivity.getStaticImageLoader(context); + } + // Update the remote controls mRemoteControl.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, (currentSong == null) ? null : currentSong.getArtist()) @@ -62,7 +67,7 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, (currentSong == null) ? 0 : ((currentSong.getDuration() == null) ? 0 : currentSong.getDuration())) .apply(); - if (currentSong == null) { + if (currentSong == null || imageLoader == null) { mRemoteControl.editMetadata(true) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, null) .apply(); |