Fix Crashes and ANRs from Play Store

This commit is contained in:
Joshua Bahnsen 2013-07-18 00:58:59 -07:00
parent b44f249cd5
commit 1f6fa55bbb
3 changed files with 16 additions and 6 deletions

View File

@ -992,13 +992,19 @@ public class DownloadServiceImpl extends Service implements DownloadService {
UltraSonicAppWidgetProvider4x4.getInstance().notifyChange(this, this, this.playerState == PlayerState.STARTED, false); UltraSonicAppWidgetProvider4x4.getInstance().notifyChange(this, this, this.playerState == PlayerState.STARTED, false);
SubsonicTabActivity tabInstance = SubsonicTabActivity.getInstance(); SubsonicTabActivity tabInstance = SubsonicTabActivity.getInstance();
Entry song = null;
if (currentPlaying != null) {
song = currentPlaying.getSong();
}
if (show) { if (show) {
int size = Util.getNotificationImageSize(this); int size = Util.getNotificationImageSize(this);
Bitmap bitmap = FileUtil.getAlbumArtBitmap(this, currentPlaying.getSong(), size, true); Bitmap bitmap = FileUtil.getAlbumArtBitmap(this, song , size, true);
if (tabInstance != null) { if (tabInstance != null) {
tabInstance.nowPlayingImage = bitmap; tabInstance.nowPlayingImage = bitmap;
tabInstance.showNotification(handler, currentPlaying.getSong(), this, this.notification, this.playerState); tabInstance.showNotification(handler, song, this, this.notification, this.playerState);
tabInstance.showNowPlaying(); tabInstance.showNowPlaying();
} }
} else { } else {

View File

@ -108,7 +108,6 @@ public class FileUtil {
if (albumArtFile.exists()) { if (albumArtFile.exists()) {
final BitmapFactory.Options opt = new BitmapFactory.Options(); final BitmapFactory.Options opt = new BitmapFactory.Options();
if (size > 0) { if (size > 0) {
opt.inJustDecodeBounds = true; opt.inJustDecodeBounds = true;
BitmapFactory.decodeFile(albumArtFile.getPath(), opt); BitmapFactory.decodeFile(albumArtFile.getPath(), opt);

View File

@ -124,7 +124,12 @@ public class SongView extends UpdateView implements Checkable {
artistTextView.setText(artist); artistTextView.setText(artist);
} }
durationTextView.setText(Util.formatTotalDuration(song.getDuration())); Integer duration = song.getDuration();
if (duration != null) {
durationTextView.setText(Util.formatTotalDuration(duration));
}
starImageView.setImageDrawable(song.getStarred() ? Util.getDrawableFromAttribute(getContext(), R.attr.star_full) : Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); starImageView.setImageDrawable(song.getStarred() ? Util.getDrawableFromAttribute(getContext(), R.attr.star_full) : Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow));
checkedTextView.setVisibility(checkable && !song.isVideo() ? View.VISIBLE : View.GONE); checkedTextView.setVisibility(checkable && !song.isVideo() ? View.VISIBLE : View.GONE);