From c20cbf7110269bce8b97b2938d32fb7141292f8f Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 17 Jan 2019 15:04:57 +0100 Subject: [PATCH] Androidx : set paging to 2.0.0 as it seems better at the moment --- app/build.gradle | 4 +-- .../timeline/paging/PagedListModelCache.kt | 30 +++---------------- matrix-sdk-android-rx/build.gradle | 2 +- matrix-sdk-android/build.gradle | 4 +-- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ec9cc85c4b..a21d6788dc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/paging/PagedListModelCache.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/paging/PagedListModelCache.kt index 6070c55202..9072a4b5b9 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/paging/PagedListModelCache.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/paging/PagedListModelCache.kt @@ -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( } } - private val asyncDiffer = @SuppressLint("RestrictedApi") - object : AsyncPagedListDiffer( + @SuppressLint("RestrictedApi") + private val asyncDiffer = AsyncPagedListDiffer( updateCallback, AsyncDifferConfig.Builder( itemDiffCallback @@ -94,27 +92,7 @@ class PagedListModelCache( 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?) { asyncDiffer.submitList(pagedList) diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle index 0d25fb6f84..26d141c37b 100644 --- a/matrix-sdk-android-rx/build.gradle +++ b/matrix-sdk-android-rx/build.gradle @@ -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' diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 255a828870..c7ca4b5d7a 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -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"