aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-16 11:32:19 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-16 11:32:19 -0800
commit5a95beb93472dea029944577d4d5c557f1aca55d (patch)
tree8a0b8adbe1b738e6f692668e22693c2b58033db2 /src/github
parentd514de5765855fc41674a3f0d4d48d057c8528e7 (diff)
downloaddsub-5a95beb93472dea029944577d4d5c557f1aca55d.tar.gz
dsub-5a95beb93472dea029944577d4d5c557f1aca55d.tar.bz2
dsub-5a95beb93472dea029944577d4d5c557f1aca55d.zip
Don't create a bitmap unless necessary, recycle after download
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 9ecfe0ad..d25d2dc9 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -25,6 +25,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
+import android.graphics.Bitmap;
import android.net.wifi.WifiManager;
import android.os.PowerManager;
import android.util.DisplayMetrics;
@@ -432,9 +433,17 @@ public class DownloadFile {
private void downloadAndSaveCoverArt(MusicService musicService) throws Exception {
try {
if (song.getCoverArt() != null) {
- DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- int size = Math.min(metrics.widthPixels, metrics.heightPixels);
- musicService.getCoverArt(context, song, size, null);
+ // Check if album art already exists, don't want to needlessly load into memory
+ File albumArtFile = FileUtil.getAlbumArtFile(context, song);
+ if(!albumArtFile.exists()) {
+ DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+ int size = Math.min(metrics.widthPixels, metrics.heightPixels);
+ Bitmap bitmap = musicService.getCoverArt(context, song, size, null);
+ // Not being used, get rid of it immediately
+ if(bitmap != null) {
+ bitmap.recycle();
+ }
+ }
}
} catch (Exception x) {
Log.e(TAG, "Failed to get cover art.", x);