From f68daaf09d0253290216df5625d0ccd3e367ee61 Mon Sep 17 00:00:00 2001 From: Joshua Bahnsen Date: Wed, 11 Dec 2013 12:45:21 -0700 Subject: [PATCH] Improve image quality with server-side scaling, catch async exceptions --- AndroidManifest.xml | 4 +-- .../activity/SelectAlbumActivity.java | 2 +- .../activity/SubsonicTabActivity.java | 2 +- .../androidapp/service/RESTMusicService.java | 16 ---------- .../androidapp/util/CacheCleaner.java | 30 +++++++++++++++++-- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 71834e1b..a509d6c0 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + a:versionCode="40" + a:versionName="1.2.0.13" > diff --git a/src/com/thejoshwa/ultrasonic/androidapp/activity/SelectAlbumActivity.java b/src/com/thejoshwa/ultrasonic/androidapp/activity/SelectAlbumActivity.java index 61b1e0c5..d24657bd 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/activity/SelectAlbumActivity.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/activity/SelectAlbumActivity.java @@ -965,7 +965,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art); int artworkSelection = random.nextInt(entries.size()); - getImageLoader().loadImage(coverArtView, entries.get(artworkSelection), true, Util.getAlbumImageSize(SelectAlbumActivity.this), false, true); + getImageLoader().loadImage(coverArtView, entries.get(artworkSelection), false, Util.getAlbumImageSize(SelectAlbumActivity.this), false, true); TextView titleView = (TextView) header.findViewById(R.id.select_album_title); titleView.setText(name != null ? name : getActionBarSubtitle()); diff --git a/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java b/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java index de610292..8060b48d 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/activity/SubsonicTabActivity.java @@ -489,7 +489,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener @Override public void run() { - getImageLoader().loadImage(nowPlayingAlbumArtImage, song, true, Util.getNotificationImageSize(context), false, true); + getImageLoader().loadImage(nowPlayingAlbumArtImage, song, false, Util.getNotificationImageSize(context), false, true); } }); diff --git a/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java b/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java index c0a2d0ab..c31c8a41 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java @@ -922,22 +922,6 @@ public class RESTMusicService implements MusicService byte[] bytes = Util.toByteArray(in); - File albumDir = FileUtil.getAlbumDirectory(context, entry); - - if (albumDir.exists()) - { - OutputStream out = null; - try - { - out = new FileOutputStream(FileUtil.getAlbumArtFile(albumDir)); - out.write(bytes); - } - finally - { - Util.close(out); - } - } - // If we aren't allowing server-side scaling, always save the file to disk because it will be unmodified if (!serverScaling || saveToFile) { diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/CacheCleaner.java b/src/com/thejoshwa/ultrasonic/androidapp/util/CacheCleaner.java index 60991dbf..8df546d1 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/CacheCleaner.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/CacheCleaner.java @@ -40,17 +40,41 @@ public class CacheCleaner public void clean() { - new BackgroundCleanup().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + try + { + new BackgroundCleanup().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + catch (Exception ex) + { + // If an exception is thrown, assume we execute correctly the next time + Log.w("Exception in CacheCleaner.clean", ex); + } } public void cleanSpace() { - new BackgroundSpaceCleanup().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + try + { + new BackgroundSpaceCleanup().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + catch (Exception ex) + { + // If an exception is thrown, assume we execute correctly the next time + Log.w("Exception in CacheCleaner.cleanSpace", ex); + } } public void cleanPlaylists(List playlists) { - new BackgroundPlaylistsCleanup().execute(playlists); + try + { + new BackgroundPlaylistsCleanup().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, playlists); + } + catch (Exception ex) + { + // If an exception is thrown, assume we execute correctly the next time + Log.w("Exception in CacheCleaner.cleanPlaylists", ex); + } } private static void deleteEmptyDirs(Iterable dirs, Collection undeletable)