[Android] TV: Improve background switching

Geoffrey Métais git at videolan.org
Fri Nov 29 11:15:24 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 26 15:39:59 2019 +0100| [7c6f0643e531c6afad6f0251d0a80cb63122c754] | committer: Nicolas Pomepuy

TV: Improve background switching

> https://code.videolan.org/videolan/vlc-android/commit/7c6f0643e531c6afad6f0251d0a80cb63122c754
---

 vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt                 | 8 +++++---
 .../src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt  | 1 +
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
index 98c1126f5..84bda9e34 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
@@ -365,8 +365,10 @@ object TvUtil {
 @Suppress("UNNECESSARY_SAFE_CALL")
 @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
 fun CoroutineScope.updateBackground(context: Context, bm: BackgroundManager?, item: Any?) {
-    if (bm === null || item === null) return
-    clearBackground(context, bm)
+    if (bm === null || item === null) {
+        clearBackground(context, bm)
+        return
+    }
     if (item is MediaLibraryItem) launch {
         val crop = item.itemType != MediaLibraryItem.TYPE_MEDIA || (item as AbstractMediaWrapper).type == AbstractMediaWrapper.TYPE_AUDIO
         val artworkMrl = item.artworkMrl
@@ -395,7 +397,7 @@ fun CoroutineScope.updateBackground(context: Context, bm: BackgroundManager?, it
     }
 }
 
-private fun clearBackground(context: Context, bm: BackgroundManager?) {
+fun clearBackground(context: Context, bm: BackgroundManager?) {
     if (bm === null) return
     bm.color = ContextCompat.getColor(context, R.color.tv_bg)
     bm.drawable = null
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
index 51ff157ba..9d1498448 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
@@ -195,6 +195,7 @@ abstract class BaseBrowserTvFragment<T> : Fragment(), BrowserFragmentInterface,
     }
 
     override fun onStart() {
+        clearBackground(requireContext(), backgroundManager)
         super.onStart()
         setFocus = true
     }



More information about the Android mailing list