[Android] TV: Set proper strings for videos

Geoffrey Métais git at videolan.org
Wed Apr 4 18:35:57 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 28 11:57:27 2018 +0200| [ad6420db405fb217c7ea3d756af21846ccbbbbb5] | committer: Geoffrey Métais

TV: Set proper strings for videos

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

 vlc-android/res/values/strings.xml                 |  1 +
 .../src/org/videolan/vlc/gui/tv/MainTvFragment.kt  | 27 +++++++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index a6e117fc2..5ad2cc744 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -556,6 +556,7 @@
     <string name="episodes">episodes</string>
     <string name="movies">movies</string>
     <string name="videos">videos</string>
+    <string name="videos_all">All videos</string>
     <string name="clear_playback_history">Clear playback history</string>
     <string name="various_artists">Various Artists</string>
     <string name="ml_scanning">Scanning for media files</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
index 3a49a60ea..8cd92c102 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
@@ -36,7 +36,6 @@ import android.support.v4.content.ContextCompat
 import android.view.View
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.Medialibrary
-import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.media.DummyItem
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaWrapper
@@ -244,19 +243,7 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
     private fun setupProviders(showHistory: Boolean) {
         videoProvider = VideosProvider.get(this, null, 0, Medialibrary.SORT_INSERTIONDATE)
         videoProvider.dataset.observe(this, Observer {
-            it?.let {
-                val list = mutableListOf<Any>()
-                list.add(DummyItem(Constants.HEADER_VIDEO, "All videos", "${it.size} ${getString(R.string.videos)}"))
-                // Update video section
-                if (!it.isEmpty()) {
-                    for ((index, video) in it.withIndex()) {
-                        if (index == NUM_ITEMS_PREVIEW) break
-                        Tools.setMediaDescription(video)
-                        list.add(video)
-                    }
-                }
-                videoAdapter.setItems(list, diffCallback)
-            }
+            updateVideos(it)
             (requireActivity() as MainTvActivity).hideLoading()
         })
         if (showHistory) {
@@ -265,4 +252,16 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
         }
         ExternalMonitor.connected.observe(this, Observer { updateBrowsers() })
     }
+
+    private fun updateVideos(videos: List<MediaWrapper>?) {
+        videos?.let {
+            val list = mutableListOf<Any>()
+            list.add(DummyItem(Constants.HEADER_VIDEO, getString(R.string.videos_all), resources.getQuantityString(R.plurals.videos_quantity, it.size, it.size)))
+            if (!it.isEmpty()) for ((index, video) in it.withIndex()) {
+                if (index == NUM_ITEMS_PREVIEW) break
+                list.add(video)
+            }
+            videoAdapter.setItems(list, diffCallback)
+        }
+    }
 }
\ No newline at end of file



More information about the Android mailing list