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

Nicolas Pomepuy git at videolan.org
Tue Dec 10 07:55:23 CET 2019


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

Avoid drawing a header at position 0 if no header exists


(cherry picked from commit 232a703b1c8e6d09b9bfdc900b8a2f0b8072009e)

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

 .../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