[Android] Fix some overscan issues

Nicolas Pomepuy git at videolan.org
Fri Jun 21 14:07:08 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Jun 20 15:26:54 2019 +0200| [bb551a2e7a6af49d27d572f7778c73bdc2678a97] | committer: Geoffrey Métais

Fix some overscan issues

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

 vlc-android/res/layout/activity_media_list_tv.xml         |  5 +++--
 .../src/org/videolan/vlc/gui/tv/TvFocusableAdapter.kt     |  8 ++++++++
 vlc-android/src/org/videolan/vlc/gui/tv/TvItemAdapter.kt  |  3 +--
 .../org/videolan/vlc/gui/tv/details/MediaListAdapter.kt   | 15 ++++++++++++++-
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/vlc-android/res/layout/activity_media_list_tv.xml b/vlc-android/res/layout/activity_media_list_tv.xml
index 2bb5c945e..8e0d9baa8 100644
--- a/vlc-android/res/layout/activity_media_list_tv.xml
+++ b/vlc-android/res/layout/activity_media_list_tv.xml
@@ -61,7 +61,7 @@
             android:id="@+id/cover"
             android:layout_width="0dp"
             android:layout_height="90dp"
-            android:layout_marginStart="24dp"
+            android:layout_marginStart="@dimen/tv_overscan_horizontal"
             android:layout_marginBottom="8dp"
             android:background="@{cover}"
             app:imageWidth="@{imageWidth}"
@@ -179,12 +179,13 @@
             </LinearLayout>
         </HorizontalScrollView>
 
-        <androidx.recyclerview.widget.RecyclerView
+        <org.videolan.vlc.gui.tv.FocusableRecyclerView
             android:id="@+id/media_list"
             android:layout_width="800dp"
             android:layout_height="0dp"
             android:clipToPadding="false"
             android:paddingTop="40dp"
+            android:paddingBottom="150dp"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvFocusableAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TvFocusableAdapter.kt
new file mode 100644
index 000000000..8d29e014d
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvFocusableAdapter.kt
@@ -0,0 +1,8 @@
+package org.videolan.vlc.gui.tv
+
+/**
+ * Callback used when the adapter is used in a [FocusableRecyclerView]
+ */
+interface TvFocusableAdapter {
+    fun setOnFocusChangeListener(focusListener: FocusableRecyclerView.FocusListener?)
+}
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvItemAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TvItemAdapter.kt
index 2313b2b3e..98c187d2a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TvItemAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvItemAdapter.kt
@@ -1,8 +1,7 @@
 package org.videolan.vlc.gui.tv
 
-interface TvItemAdapter {
+interface TvItemAdapter : TvFocusableAdapter {
     fun submitList(pagedList: Any?)
-    fun setOnFocusChangeListener(focusListener: FocusableRecyclerView.FocusListener?)
 
     var focusNext: Int
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListAdapter.kt
index 0f1f58672..d10473f47 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListAdapter.kt
@@ -16,11 +16,21 @@ import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.databinding.ActivityMediaListTvItemBinding
 import org.videolan.vlc.gui.DiffUtilAdapter
 import org.videolan.vlc.gui.helpers.SelectorViewHolder
+import org.videolan.vlc.gui.tv.FocusableRecyclerView
+import org.videolan.vlc.gui.tv.TvFocusableAdapter
 import org.videolan.vlc.interfaces.ITVEventsHandler
 
 @ExperimentalCoroutinesApi
 @ObsoleteCoroutinesApi
-class MediaListAdapter(private val type: Int, private val listener: ITVEventsHandler) : DiffUtilAdapter<MediaWrapper, MediaListAdapter.MediaListViewHolder>() {
+class MediaListAdapter(private val type: Int, private val listener: ITVEventsHandler) : DiffUtilAdapter<MediaWrapper, MediaListAdapter.MediaListViewHolder>(), TvFocusableAdapter {
+
+    private var focusListener: FocusableRecyclerView.FocusListener? = null
+
+
+    override fun setOnFocusChangeListener(focusListener: FocusableRecyclerView.FocusListener?) {
+        this.focusListener = focusListener
+    }
+
 
     var lastMovedItemFrom = -1
     var lastMovedItemTo = -1
@@ -81,6 +91,9 @@ class MediaListAdapter(private val type: Int, private val listener: ITVEventsHan
                 if (hasFocus) {
                     listener.onFocusChanged(getItem(layoutPosition))
                 }
+                if (hasFocus) {
+                    focusListener?.onFocusChanged(layoutPosition)
+                }
 
             }
 



More information about the Android mailing list