From 0190b396904012841f3d938d8db9d115321cc716 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 18 Feb 2014 06:40:32 -0800 Subject: #276 Clear the bitmap cache when exiting the application --- src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 2 ++ src/github/daneren2005/dsub/util/ImageLoader.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 9c8bcaa3..982c7f80 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -55,6 +55,7 @@ import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.updates.Updater; +import github.daneren2005.dsub.util.BackgroundTask; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.SilentBackgroundTask; @@ -81,6 +82,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) { stopService(new Intent(this, DownloadService.class)); finish(); + getImageLoader().clearCache(); } else if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD)) { DownloadService service = getDownloadService(); boolean downloadView = getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW); diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java index 10b6434e..88ea37ee 100644 --- a/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/src/github/daneren2005/dsub/util/ImageLoader.java @@ -88,6 +88,11 @@ public class ImageLoader { createLargeUnknownImage(context); } + public void clearCache() { + nowPlaying = null; + cache.evictAll(); + } + private void createLargeUnknownImage(Context context) { BitmapDrawable drawable = (BitmapDrawable) context.getResources().getDrawable(R.drawable.unknown_album_large); Bitmap bitmap = Bitmap.createScaledBitmap(drawable.getBitmap(), imageSizeLarge, imageSizeLarge, true); -- cgit v1.2.3