[Android] Fix icon in notification
Geoffrey Métais
git at videolan.org
Mon Dec 29 13:38:15 CET 2014
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 29 13:36:16 2014 +0100| [91e35f10fd1ff96a6281d49a01c0df9cc98d4d7e] | committer: Geoffrey Métais
Fix icon in notification
When playing a song with no cover, the previous song cover was displayed instead of VLC icon
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=91e35f10fd1ff96a6281d49a01c0df9cc98d4d7e
---
vlc-android/src/org/videolan/vlc/audio/AudioService.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 05563b8..5ab19b5 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -69,6 +69,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.media.AudioManager.OnAudioFocusChangeListener;
import android.media.MediaMetadataRetriever;
@@ -762,8 +763,7 @@ public class AudioService extends Service {
PendingIntent piStop = PendingIntent.getBroadcast(this, 0, iStop, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
- if (cover != null)
- view.setImageViewBitmap(R.id.cover, cover);
+ view.setImageViewBitmap(R.id.cover, cover == null ? BitmapFactory.decodeResource(getResources(), R.drawable.icon) : cover);
view.setTextViewText(R.id.songName, title);
view.setTextViewText(R.id.artist, artist);
view.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w);
@@ -773,8 +773,7 @@ public class AudioService extends Service {
view.setOnClickPendingIntent(R.id.content, pendingIntent);
RemoteViews view_expanded = new RemoteViews(getPackageName(), R.layout.notification_expanded);
- if (cover != null)
- view_expanded.setImageViewBitmap(R.id.cover, cover);
+ view_expanded.setImageViewBitmap(R.id.cover, cover == null ? BitmapFactory.decodeResource(getResources(), R.drawable.icon) : cover);
view_expanded.setTextViewText(R.id.songName, title);
view_expanded.setTextViewText(R.id.artist, artist);
view_expanded.setTextViewText(R.id.album, album);
@@ -792,7 +791,7 @@ public class AudioService extends Service {
notification.bigContentView = view_expanded;
}
else {
- builder.setLargeIcon(cover)
+ builder.setLargeIcon(cover == null ? BitmapFactory.decodeResource(getResources(), R.drawable.icon) : cover)
.setContentTitle(title)
.setContentText(LibVlcUtil.isJellyBeanOrLater() ? artist
: media.getSubtitle())
More information about the Android
mailing list