[Android] Improve TV Recommendations

Geoffrey Métais git at videolan.org
Thu Apr 23 16:44:15 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 23 16:43:53 2015 +0200| [01a69cf930230e3a2ece4193fdfbd495fc09f39d] | committer: Geoffrey Métais

Improve TV Recommendations

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=01a69cf930230e3a2ece4193fdfbd495fc09f39d
---

 .../videolan/vlc/gui/tv/RecommendationsService.java    |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java
index a529b04..b96c98f 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/RecommendationsService.java
@@ -39,6 +39,7 @@ import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.gui.PreferencesActivity;
 import org.videolan.vlc.gui.video.VideoPlayerActivity;
+import org.videolan.vlc.util.BitmapUtil;
 import org.videolan.vlc.util.WeakHandler;
 
 import java.util.ArrayList;
@@ -61,6 +62,10 @@ public class RecommendationsService extends IntentService {
     public void onCreate() {
         super.onCreate();
         mContext = this;
+        if (mNotificationManager == null) {
+            mNotificationManager = (NotificationManager)
+                    mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+        }
     }
 
     @Override
@@ -74,11 +79,6 @@ public class RecommendationsService extends IntentService {
         if (movie == null)
             return;
 
-        if (mNotificationManager == null) {
-            mNotificationManager = (NotificationManager)
-                    mContext.getSystemService(Context.NOTIFICATION_SERVICE);
-        }
-
         //TODO
 //        if (mBackgroundUri != movie.getBackgroundUri()) {
 //            extras.putString(EXTRA_BACKGROUND_IMAGE_URL, movie.getBackgroundUri());
@@ -93,16 +93,15 @@ public class RecommendationsService extends IntentService {
                         .setPriority(priority)
                         .setLocalOnly(true)
                         .setOngoing(true)
-                        .setColor(mContext.getResources().getColor(R.color.orange500))
+                        .setColor(mContext.getResources().getColor(R.color.orange800))
                         .setCategory("recommendation")
-                        .setLargeIcon(mMediaDatabase.getPicture(mContext, movie.getLocation()))
+                        .setLargeIcon(BitmapUtil.getPictureFromCache(movie))
                         .setSmallIcon(R.drawable.icon)
                         .setContentIntent(buildPendingIntent(movie, id))
         ).build();
 
         // post the recommendation to the NotificationManager
         mNotificationManager.notify(id, notification);
-        mNotificationManager = null;
     }
 
     private PendingIntent buildPendingIntent(MediaWrapper mediaWrapper, int id) {
@@ -130,6 +129,7 @@ public class RecommendationsService extends IntentService {
     }
 
     private boolean doRecommendations() {
+        mNotificationManager.cancelAll();
         String last = Uri.decode(PreferenceManager.getDefaultSharedPreferences(mContext).getString(PreferencesActivity.VIDEO_LAST, null));
         int id = 0;
         if (last != null) {



More information about the Android mailing list