[Android] Set background colors for TV

Geoffrey Métais git at videolan.org
Thu Jul 9 18:53:59 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul  9 18:38:06 2015 +0200| [df3fea0209daa388ab18c91c8ddf96eb1ddd4722] | committer: Geoffrey Métais

Set background colors for TV

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

 .../src/org/videolan/vlc/gui/tv/MainTvActivity.java   |   12 +++++++++---
 .../vlc/gui/tv/browser/VerticalGridActivity.java      |   17 +++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index eb6741e..b5cab46 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -85,6 +85,7 @@ public class MainTvActivity extends PlaybackServiceActivity implements IVideoBro
     public static final String TAG = "VLC/MainTvActivity";
 
     protected BrowseFragment mBrowseFragment;
+    private BackgroundManager mBackgroundManager;
     private ProgressBar mProgressBar;
     protected final CyclicBarrier mBarrier = new CyclicBarrier(2);
     private static Thumbnailer sThumbnailer;
@@ -134,7 +135,8 @@ public class MainTvActivity extends PlaybackServiceActivity implements IVideoBro
             mBrowseFragment.setSearchAffordanceColor(getResources().getColor(R.color.orange500));
         }
         mRootContainer = mBrowseFragment.getView();
-        BackgroundManager.getInstance(this).attach(getWindow());
+        mBackgroundManager = BackgroundManager.getInstance(this);
+        mBackgroundManager.attach(getWindow());
     }
 
     @Override
@@ -165,11 +167,15 @@ public class MainTvActivity extends PlaybackServiceActivity implements IVideoBro
 
         if (mMediaLibrary.isWorking()) //Display UI while MediaLib is scanning
             updateList();
+
+        mBrowseFragment.setBrandColor(getResources().getColor(R.color.orange800));
+        mBackgroundManager.setColor(getResources().getColor(R.color.grey700));
     }
 
     protected void onPause() {
         super.onPause();
         mMediaLibrary.removeUpdateHandler(mHandler);
+        mBackgroundManager.release();
 
         /* Stop the thumbnailer */
         if (sThumbnailer != null)
@@ -219,11 +225,11 @@ public class MainTvActivity extends PlaybackServiceActivity implements IVideoBro
     }
 
     protected void updateBackground(Drawable drawable) {
-        BackgroundManager.getInstance(this).setDrawable(drawable);
+        mBackgroundManager.setDrawable(drawable);
     }
 
     protected void clearBackground() {
-        BackgroundManager.getInstance(this).setDrawable(mDefaultBackground);
+        mBackgroundManager.setDrawable(mDefaultBackground);
     }
 
     public void await() throws InterruptedException, BrokenBarrierException {
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
index 9a51ef5..f15d2b5 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
@@ -22,6 +22,7 @@ package org.videolan.vlc.gui.tv.browser;
 
 import android.content.Intent;
 import android.os.Bundle;
+import android.support.v17.leanback.app.BackgroundManager;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.ProgressBar;
@@ -35,6 +36,7 @@ import org.videolan.vlc.gui.tv.SearchActivity;
 public class VerticalGridActivity extends PlaybackServiceActivity implements GridFragment.BrowserActivity {
 
     GridFragment mFragment;
+    private BackgroundManager mBackgroundManager;
     ProgressBar mContentLoadingProgressBar;
     TextView mEmptyView;
 
@@ -59,6 +61,21 @@ public class VerticalGridActivity extends PlaybackServiceActivity implements Gri
         getFragmentManager().beginTransaction()
                 .add(R.id.tv_fragment_placeholder, mFragment)
                 .commit();
+        mBackgroundManager = BackgroundManager.getInstance(this);
+        mBackgroundManager.attach(getWindow());
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        mBackgroundManager.setColor(getResources().getColor(R.color.grey700));
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mBackgroundManager.release();
     }
 
     @Override



More information about the Android mailing list