[Android] Fix header regression

Nicolas Pomepuy git at videolan.org
Thu Apr 11 18:38:00 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Apr  5 09:49:26 2019 +0200| [f0b703a6bde21635161d4c9de87aa31cd15e59a0] | committer: Geoffrey Métais

Fix header regression

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

 .../vlc/gui/tv/browser/AudioBrowserTvFragment.kt      |  4 ++--
 .../vlc/gui/view/RecyclerSectionItemGridDecoration.kt | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/AudioBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/AudioBrowserTvFragment.kt
index 8553b60c7..4a4e2443e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/AudioBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/AudioBrowserTvFragment.kt
@@ -71,7 +71,7 @@ class AudioBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEventsHand
     private var nbColumns: Int = 0
     private lateinit var gridLayoutManager: GridLayoutManager
     private var currentItem: MediaLibraryItem? = null
-    private lateinit var currentArt: String
+    private var currentArt: String? = null
     private lateinit var backgroundManager: BackgroundManager
 
     companion object {
@@ -295,7 +295,7 @@ class AudioBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEventsHand
 
     override fun onItemFocused(v: View, item: MediaLibraryItem) {
         (item as? MediaLibraryItem)?.run {
-            if (::currentArt.isInitialized && currentArt == artworkMrl) return at run
+            if (currentArt == artworkMrl) return at run
             currentArt = artworkMrl
             TvUtil.updateBackground(backgroundManager, this)
         }
diff --git a/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemGridDecoration.kt b/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemGridDecoration.kt
index b52fa1cf8..8991fa738 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemGridDecoration.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemGridDecoration.kt
@@ -10,6 +10,7 @@ import android.widget.TextView
 import androidx.recyclerview.widget.RecyclerView
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
+import org.videolan.vlc.util.AndroidDevices
 import org.videolan.vlc.viewmodels.paged.MLPagedModel
 
 private const val TAG = "RecyclerSectionItemDecoration"
@@ -36,17 +37,16 @@ class RecyclerSectionItemGridDecoration(private val headerOffset: Int, private v
         }
 
 
-
     }
 
     override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
         super.onDrawOver(c, parent, state)
 
-//        if (!::headerView.isInitialized) {
-        headerView = inflateHeaderView(parent)
-        header = headerView.findViewById(R.id.section_header) as TextView
-        fixLayoutSize(headerView, parent)
-//        }
+        if (!::headerView.isInitialized) {
+            headerView = inflateHeaderView(parent)
+            header = headerView.findViewById(R.id.section_header) as TextView
+            fixLayoutSize(headerView, parent)
+        }
 
 
         //draw current header
@@ -101,8 +101,11 @@ class RecyclerSectionItemGridDecoration(private val headerOffset: Int, private v
     }
 
     private fun inflateHeaderView(parent: RecyclerView): View {
-        return LayoutInflater.from(parent.context)
-                .inflate(R.layout.recycler_section_header_tv, parent, false)
+        if (AndroidDevices.showTvUi(parent.context)) {
+            return LayoutInflater.from(parent.context).inflate(R.layout.recycler_section_header_tv, parent, false)
+        }
+        return LayoutInflater.from(parent.context).inflate(R.layout.recycler_section_header, parent, false)
+
     }
 
     /**



More information about the Android mailing list