[Android] Set search in groups & folders providers

Geoffrey Métais git at videolan.org
Wed Apr 29 09:03:35 CEST 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 27 16:02:54 2020 +0200| [48f7df04bbea05345ab3962bcfd45b51754a9fd9] | committer: Nicolas Pomepuy

Set search in groups & folders providers

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

 .../org/videolan/vlc/providers/medialibrary/FoldersProvider.kt   | 8 ++++++--
 .../videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt   | 9 ++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/FoldersProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/FoldersProvider.kt
index 9954f68b1..97446aa3d 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/FoldersProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/FoldersProvider.kt
@@ -30,8 +30,12 @@ import org.videolan.vlc.viewmodels.SortableModel
 class FoldersProvider(context: Context, model: SortableModel, val type: Int) : MedialibraryProvider<Folder>(context, model) {
     override fun getAll() : Array<Folder> = medialibrary.getFolders(type, sort, desc, getTotalCount(), 0)
 
-    override fun getTotalCount() = medialibrary.getFoldersCount(type)
+    override fun getTotalCount() = if (model.filterQuery.isNullOrEmpty()) medialibrary.getFoldersCount(type) else medialibrary.getFoldersCount(model.filterQuery)
 
-    override fun getPage(loadSize: Int, startposition: Int) : Array<Folder> = medialibrary.getFolders(type, sort, desc, loadSize, startposition).also { completeHeaders(it, startposition) }
+    override fun getPage(loadSize: Int, startposition: Int) : Array<Folder> = if (model.filterQuery.isNullOrEmpty()) {
+        medialibrary.getFolders(type, sort, desc, loadSize, startposition).also { completeHeaders(it, startposition) }
+    } else {
+        medialibrary.searchFolders(model.filterQuery, sort, desc, loadSize, startposition)
+    }
 
 }
\ No newline at end of file
diff --git a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
index e5e50a21b..67c3cac9c 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
@@ -16,10 +16,13 @@ class VideoGroupsProvider(context: Context, model: SortableModel) : Medialibrary
 
     override fun getAll() : Array<MediaLibraryItem> = medialibrary.getVideoGroups(sort, desc, getTotalCount(), 0).extractSingles()
 
-    override fun getTotalCount() = if (model.filterQuery == null) medialibrary.videoGroupsCount
-    else medialibrary.videoGroupsCount
+    override fun getTotalCount() = medialibrary.getVideoGroupsCount(model.filterQuery)
 
-    override fun getPage(loadSize: Int, startposition: Int) : Array<MediaLibraryItem> = medialibrary.getVideoGroups(sort, desc, loadSize, startposition).extractSingles().also { if (Settings.showTvUi) completeHeaders(it, startposition) }
+    override fun getPage(loadSize: Int, startposition: Int) : Array<MediaLibraryItem> = if (model.filterQuery.isNullOrEmpty()) {
+        medialibrary.getVideoGroups(sort, desc, loadSize, startposition)
+    } else {
+        medialibrary.searchVideoGroups(model.filterQuery, sort, desc, loadSize, startposition)
+    }.extractSingles().also { if (Settings.showTvUi)completeHeaders(it, startposition) }
 }
 
 private fun Array<VideoGroup>.extractSingles() = map {



More information about the Android mailing list