From ad7ea3cc9ef017a6090c93b428f60aeed718b340 Mon Sep 17 00:00:00 2001 From: Joshua Bahnsen Date: Sun, 26 Jan 2014 20:43:34 -0700 Subject: [PATCH] Resolve crashes from 1.3.0.5 --- .../service/DownloadServiceImpl.java | 14 +++++--------- .../ultrasonic/androidapp/util/FileUtil.java | 19 +++++++++++++++++-- .../androidapp/util/ImageLoader.java | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/com/thejoshwa/ultrasonic/androidapp/service/DownloadServiceImpl.java b/src/com/thejoshwa/ultrasonic/androidapp/service/DownloadServiceImpl.java index 9b1c546d..14e31535 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/service/DownloadServiceImpl.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/service/DownloadServiceImpl.java @@ -1566,16 +1566,12 @@ public class DownloadServiceImpl extends Service implements DownloadService String artist = currentSong.getArtist(); String album = currentSong.getAlbum(); String title = currentSong.getTitle(); - //String genre = currentSong.getGenre(); - //Integer track = currentSong.getTrack(); - //Integer disc = currentSong.getDiscNumber(); - Long duration = (long) currentSong.getDuration() * 1000; + Integer currentSongDuration = currentSong.getDuration(); + Long duration = 0L; - remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album).putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title) - //.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, genre) - .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration) - //.putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, track) - //.putLong(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, disc) + if (currentSongDuration != null) duration = (long) currentSongDuration * 1000; + + remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album).putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title).putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, lockScreenBitmap).apply(); } } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/FileUtil.java b/src/com/thejoshwa/ultrasonic/androidapp/util/FileUtil.java index 199557b1..7ddc713b 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/FileUtil.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/FileUtil.java @@ -130,7 +130,19 @@ public class FileUtil File albumArtFile = getAlbumArtFile(context, entry); - Bitmap bitmap = SubsonicTabActivity.getInstance().getImageLoader().getImageBitmap(entry, true, size); + SubsonicTabActivity subsonicTabActivity = SubsonicTabActivity.getInstance(); + Bitmap bitmap = null; + ImageLoader imageLoader = null; + + if (subsonicTabActivity != null) + { + imageLoader = subsonicTabActivity.getImageLoader(); + + if (imageLoader != null) + { + bitmap = imageLoader.getImageBitmap(entry, true, size); + } + } if (bitmap != null) { @@ -162,7 +174,10 @@ public class FileUtil if (bitmap != null) { - SubsonicTabActivity.getInstance().getImageLoader().addImageToCache(bitmap, entry, size); + if (imageLoader != null) + { + imageLoader.addImageToCache(bitmap, entry, size); + } } return bitmap == null ? null : bitmap; diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/ImageLoader.java b/src/com/thejoshwa/ultrasonic/androidapp/util/ImageLoader.java index 43b0e819..5bbb688c 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/ImageLoader.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/ImageLoader.java @@ -135,6 +135,8 @@ public class ImageLoader implements Runnable public void loadImage(View view, MusicDirectory.Entry entry, boolean large, int size, boolean crossFade, boolean highQuality) { + view.invalidate(); + if (entry == null) { setUnknownImage(view, large);