Improve image quality with server-side scaling, catch async exceptions

This commit is contained in:
Joshua Bahnsen 2013-12-11 12:45:21 -07:00
parent 98ca08badd
commit f68daaf09d
5 changed files with 31 additions and 23 deletions

View File

@ -2,8 +2,8 @@
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
package="com.thejoshwa.ultrasonic.androidapp"
a:installLocation="auto"
a:versionCode="39"
a:versionName="1.2.0.12" >
a:versionCode="40"
a:versionName="1.2.0.13" >
<uses-permission a:name="android.permission.INTERNET" />
<uses-permission a:name="android.permission.READ_PHONE_STATE" />

View File

@ -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());

View File

@ -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);
}
});

View File

@ -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)
{

View File

@ -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<Playlist> 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<File> dirs, Collection<File> undeletable)