[Android] Avoid drawing a header at position 0 if no header exists

Nicolas Pomepuy git at videolan.org
Fri Dec 6 12:34:42 CET 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Dec  6 08:59:22 2019 +0000| [e382ddfabb8b4de29af0693847b0277d7335860d] | committer: Geoffrey Métais

Avoid drawing a header at position 0 if no header exists


(cherry picked from commit 232a703b1c8e6d09b9bfdc900b8a2f0b8072009e)

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

 .../org/videolan/vlc/gui/view/RecyclerSectionItemDecoration.kt | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemDecoration.kt b/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemDecoration.kt
index a381abd95..44840d12f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemDecoration.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/RecyclerSectionItemDecoration.kt
@@ -45,11 +45,13 @@ class RecyclerSectionItemDecoration(private val headerOffset: Int, private val s
         if (sticky && previousChild != null) {
             val position = parent.getChildAdapterPosition(previousChild)
             val sectionPosition = provider.getPositionForSection(position)
-            previousSectionPosition = sectionPosition
+            if (provider.getHeaderForPostion(sectionPosition) != null) {
+                previousSectionPosition = sectionPosition
 
-            val title = provider.getSectionforPosition(sectionPosition)
-            header.text = title
-            drawHeader(c, parent.getChildAt(0), headerView)
+                val title = provider.getSectionforPosition(sectionPosition)
+                header.text = title
+                drawHeader(c, parent.getChildAt(0), headerView)
+            }
         }
 
         val drawnPositions = ArrayList<Int>()



More information about the Android mailing list