Commit c8d59d68 authored by Geoffrey Métais's avatar Geoffrey Métais

Upgrade paging to v 2.1.0 with ktx extension

parent 244825ea
......@@ -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'
......
......@@ -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"
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment