[Android] Adjust page size when it's lower than loadSize
Geoffrey Métais
git at videolan.org
Wed Nov 14 15:52:03 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 14 15:51:00 2018 +0100| [723a53d75dac8c78c0f69fe0ba2a078bfacde31d] | committer: Geoffrey Métais
Adjust page size when it's lower than loadSize
> https://code.videolan.org/videolan/vlc-android/commit/723a53d75dac8c78c0f69fe0ba2a078bfacde31d
---
vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
index 892244274..a7470fd8f 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
@@ -81,8 +81,9 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
inner class MLDataSource : PositionalDataSource<T>() {
override fun loadInitial(params: LoadInitialParams, callback: LoadInitialCallback<T>) {
- val count = getTotalCount()
- callback.onResult(getPage(params.requestedLoadSize, params.requestedStartPosition).toList(), params.requestedStartPosition, count)
+ val page = getPage(params.requestedLoadSize, params.requestedStartPosition)
+ val count = if (page.size < params.requestedLoadSize) page.size else getTotalCount()
+ callback.onResult(page.toList(), params.requestedStartPosition, count)
loading.postValue(false)
}
override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<T>) {
More information about the Android
mailing list