[Android] Hide protocol when not on root level on TV

Nicolas Pomepuy git at videolan.org
Wed Sep 25 16:28:53 CEST 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Sep 25 11:05:47 2019 +0200| [d8616f57bc0f0b9a8b3d1b06be5f4ef4d1a2e512] | committer: Geoffrey Métais

Hide protocol when not on root level on TV

(cherry picked from commit e45bdc01660005eca92e4b45b83065b903121a8f)

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

 vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt     | 9 ++++-----
 .../src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 3 +--
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
index d0bd0f91b..e66dc3697 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
@@ -24,11 +24,10 @@ import org.videolan.vlc.gui.view.FastScroller
 import org.videolan.vlc.interfaces.IEventsHandler
 import org.videolan.vlc.util.UPDATE_PAYLOAD
 import org.videolan.vlc.util.generateResolutionClass
-import org.videolan.vlc.viewmodels.browser.TYPE_NETWORK
 
 @ExperimentalCoroutinesApi
 @ObsoleteCoroutinesApi
-class FileTvItemAdapter(private val type: Long, private val eventsHandler: IEventsHandler, var itemSize: Int) : DiffUtilAdapter<AbstractMediaWrapper, MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>>(), FastScroller.SeparatedAdapter, TvItemAdapter {
+class FileTvItemAdapter(private val type: Long, private val eventsHandler: IEventsHandler, var itemSize: Int, val showProtocol: Boolean) : DiffUtilAdapter<AbstractMediaWrapper, MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>>(), FastScroller.SeparatedAdapter, TvItemAdapter {
 
     override fun submitList(pagedList: Any?) {
         if (pagedList is List<*>) {
@@ -53,7 +52,7 @@ class FileTvItemAdapter(private val type: Long, private val eventsHandler: IEven
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding> {
         val inflater = parent.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
         val binding = MediaBrowserTvItemBinding.inflate(inflater, parent, false)
-        return MediaItemTVViewHolder(binding, eventsHandler)
+        return MediaItemTVViewHolder(binding, eventsHandler, showProtocol)
     }
 
     override fun onBindViewHolder(holder: MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>, position: Int) {
@@ -100,7 +99,7 @@ class FileTvItemAdapter(private val type: Long, private val eventsHandler: IEven
     }
 
     inner class MediaItemTVViewHolder @TargetApi(Build.VERSION_CODES.M)
-    internal constructor(binding: MediaBrowserTvItemBinding, override val eventsHandler: IEventsHandler) : MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>(binding), View.OnFocusChangeListener {
+    internal constructor(binding: MediaBrowserTvItemBinding, override val eventsHandler: IEventsHandler, private val showProtocol: Boolean) : MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>(binding), View.OnFocusChangeListener {
 
         override fun getItem(layoutPosition: Int) = this at FileTvItemAdapter.getItem(layoutPosition)
 
@@ -172,7 +171,7 @@ class FileTvItemAdapter(private val type: Long, private val eventsHandler: IEven
             binding.isSquare = isSquare
             binding.seen = seen
             binding.description = description
-            if (type == TYPE_NETWORK && item is AbstractMediaWrapper) binding.protocol = getProtocol(item)
+            if (showProtocol && item is AbstractMediaWrapper) binding.protocol = getProtocol(item)
             val cover = if (item is AbstractMediaWrapper) getMediaIconDrawable(binding.root.context, item.type, true) else defaultCover
             cover?.let { binding.cover = it }
             if (seen == 0L) binding.mlItemSeen.visibility = View.GONE
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index c9067f5df..d136f71f5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -10,7 +10,6 @@ import androidx.core.content.ContextCompat
 import androidx.fragment.app.FragmentManager
 import androidx.lifecycle.Observer
 import androidx.lifecycle.ViewModelProviders
-import androidx.recyclerview.widget.DividerItemDecoration
 import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
@@ -85,7 +84,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
     }
 
     override fun provideAdapter(eventsHandler: IEventsHandler, itemSize: Int): TvItemAdapter {
-        return FileTvItemAdapter(getCategory(), this, itemSize)
+        return FileTvItemAdapter(getCategory(), this, itemSize, isRootLevel)
     }
 
     override fun onCreate(savedInstanceState: Bundle?) {



More information about the Android mailing list