[Android] Upgrade paging to v 2.1.0 with ktx extension
Geoffrey Métais
git at videolan.org
Fri Mar 29 16:30:25 CET 2019
vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 20 17:45:58 2019 +0100| [012ef47972e8f6c4cac08f52cfa7a36a3edf8573] | committer: Geoffrey Métais
Upgrade paging to v 2.1.0 with ktx extension
(cherry picked from commit c8d59d68d2e60f0eacf977215ceef82af743fa00)
> https://code.videolan.org/videolan/vlc-android/commit/012ef47972e8f6c4cac08f52cfa7a36a3edf8573
---
build.gradle | 2 +-
vlc-android/build.gradle | 2 +-
.../org/videolan/vlc/viewmodels/paged/MLPagedModel.kt | 19 ++++++++++---------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/build.gradle b/build.gradle
index 5b5700f32..a1eb0c9c6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -42,7 +42,7 @@ ext {
constraintLayoutVersion = '1.1.3'
archVersion = '2.0.0'
roomVersion = '2.0.0'
- pagingVersion = '2.0.0'
+ pagingVersion = '2.1.0'
junitVersion = '4.12'
mockito = '2.8.9'
powerMock = '1.7.4'
diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index 5632232f5..e66765081 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -231,7 +231,7 @@ dependencies {
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.ext.archVersion"
implementation "androidx.room:room-runtime:$rootProject.ext.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.ext.roomVersion"
- implementation "androidx.paging:paging-runtime:$rootProject.ext.pagingVersion"
+ implementation "androidx.paging:paging-runtime-ktx:$rootProject.ext.pagingVersion"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofit"
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 3c779b44a..d82f87bda 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
@@ -5,10 +5,10 @@ import androidx.annotation.MainThread
import androidx.collection.SparseArrayCompat
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
+import androidx.paging.Config
import androidx.paging.DataSource
-import androidx.paging.LivePagedListBuilder
-import androidx.paging.PagedList
import androidx.paging.PositionalDataSource
+import androidx.paging.toLiveData
import kotlinx.coroutines.*
import org.videolan.medialibrary.Medialibrary
import org.videolan.medialibrary.media.MediaLibraryItem
@@ -29,14 +29,15 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
private val headers = HeadersIndex()
val liveHeaders : LiveData<HeadersIndex> = MutableLiveData<HeadersIndex>()
- private val pagingConfig = PagedList.Config.Builder()
- .setPageSize(MEDIALIBRARY_PAGE_SIZE)
- .setPrefetchDistance(MEDIALIBRARY_PAGE_SIZE / 5)
- .setEnablePlaceholders(true)
- .build()
+ private val pagingConfig = Config(
+ pageSize = MEDIALIBRARY_PAGE_SIZE,
+ prefetchDistance = MEDIALIBRARY_PAGE_SIZE / 5,
+ enablePlaceholders = true,
+ initialLoadSizeHint = MEDIALIBRARY_PAGE_SIZE*3,
+ maxSize = MEDIALIBRARY_PAGE_SIZE*3
+ )
- val pagedList = LivePagedListBuilder(MLDatasourceFactory(), pagingConfig)
- .build()
+ val pagedList = MLDatasourceFactory().toLiveData(pagingConfig)
init {
medialibrary.addOnMedialibraryReadyListener(this)
More information about the Android
mailing list