[Android] Speed up loading of large collections
Geoffrey Métais
git at videolan.org
Tue Feb 12 15:15:17 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 12 15:13:30 2019 +0100| [d003f731b4bdbe73e3e940cfc1d6127551ba076d] | committer: Geoffrey Métais
Speed up loading of large collections
> https://code.videolan.org/videolan/vlc-android/commit/d003f731b4bdbe73e3e940cfc1d6127551ba076d
---
vlc-android/src/org/videolan/vlc/media/MediaUtils.kt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
index daf4ee934..e7bed6216 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
@@ -183,13 +183,15 @@ object MediaUtils : CoroutineScope {
in 1..MEDIALIBRARY_PAGE_SIZE -> play(withContext(Dispatchers.IO) { model.getAll().toList() })
else -> {
var index = 0
+ val appendList = mutableListOf<MediaWrapper>()
while (index < count) {
val pageCount = min(MEDIALIBRARY_PAGE_SIZE, count - index)
val list = withContext(Dispatchers.IO) { model.getPage(pageCount, index).toList() }
if (index == 0) play(list)
- else service.append(list)
+ else appendList.addAll(list)
index += pageCount
}
+ service.append(appendList)
}
}
}
More information about the Android
mailing list