Androidx : set paging to 2.0.0 as it seems better at the moment

This commit is contained in:
ganfra 2019-01-17 15:04:57 +01:00
parent ac2d20ad3f
commit c20cbf7110
4 changed files with 9 additions and 31 deletions

View File

@ -49,15 +49,15 @@ dependencies {
def epoxy_version = "3.0.0"
def arrow_version = "0.8.2"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":matrix-sdk-android")
implementation project(":matrix-sdk-android-rx")

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// Paging
implementation 'androidx.paging:paging-runtime:2.1.0-rc01'
implementation 'androidx.paging:paging-runtime:2.0.0'

implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1'
implementation 'com.jakewharton.timber:timber:4.7.1'

View File

@ -17,14 +17,12 @@
package im.vector.riotredesign.features.home.room.detail.timeline.paging

import android.annotation.SuppressLint
import android.os.Handler
import androidx.paging.AsyncPagedListDiffer
import androidx.paging.PagedList
import android.os.Handler
import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListUpdateCallback
import android.util.Log
import com.airbnb.epoxy.EpoxyController
import com.airbnb.epoxy.EpoxyModel
import java.util.concurrent.Executor
import java.util.concurrent.atomic.AtomicBoolean
@ -79,8 +77,8 @@ class PagedListModelCache<T>(
}
}

private val asyncDiffer = @SuppressLint("RestrictedApi")
object : AsyncPagedListDiffer<T>(
@SuppressLint("RestrictedApi")
private val asyncDiffer = AsyncPagedListDiffer<T>(
updateCallback,
AsyncDifferConfig.Builder<T>(
itemDiffCallback
@ -94,27 +92,7 @@ class PagedListModelCache<T>(
modelBuildingHandler.post(runnable)
}
}.build()
) {
init {
if (modelBuildingHandler != EpoxyController.defaultModelBuildingHandler) {
try {
// looks like AsyncPagedListDiffer in 1.x ignores the config.
// Reflection to the rescue.
val mainThreadExecutorField =
AsyncPagedListDiffer::class.java.getDeclaredField("mMainThreadExecutor")
mainThreadExecutorField.isAccessible = true
mainThreadExecutorField.set(this, Executor {
modelBuildingHandler.post(it)
})
} catch (t: Throwable) {
val msg = "Failed to hijack update handler in AsyncPagedListDiffer." +
"You can only build models on the main thread"
Log.e("PagedListModelCache", msg, t)
throw IllegalStateException(msg, t)
}
}
}
}
)

fun submitList(pagedList: PagedList<T>?) {
asyncDiffer.submitList(pagedList)

View File

@ -40,7 +40,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

// Paging
implementation 'androidx.paging:paging-runtime:2.1.0-rc01'
implementation 'androidx.paging:paging-runtime:2.0.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'

View File

@ -49,7 +49,7 @@ dependencies {
def arrow_version = "0.8.0"
def support_version = '1.1.0-alpha01'
def moshi_version = '1.8.0'
def lifecycle_version = '2.0.0-beta01'
def lifecycle_version = '2.0.0'
def coroutines_version = "1.0.1"

implementation fileTree(dir: 'libs', include: ['*.aar'])
@ -77,7 +77,7 @@ dependencies {
kapt 'dk.ilios:realmfieldnameshelper:1.1.1'

// Paging
implementation 'androidx.paging:paging-runtime:2.1.0-rc01'
implementation 'androidx.paging:paging-runtime:2.0.0'

// Work
implementation "android.arch.work:work-runtime-ktx:1.0.0-beta02"