From bab178166ddf02851039f88671a6d457b01c23e4 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 13 Mar 2023 13:16:49 +0100 Subject: [PATCH] update AndroidX lifecycle to 2.6.0, fix deprecation (#3443) --- .../conversation/ConversationsFragment.kt | 17 ++++++++++++----- gradle/libs.versions.toml | 10 +++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt index 2d68db934..58a1f18e3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsFragment.kt @@ -28,6 +28,7 @@ import androidx.core.view.MenuProvider import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import androidx.paging.LoadState import androidx.preference.PreferenceManager import androidx.recyclerview.widget.DividerItemDecoration @@ -189,11 +190,17 @@ class ConversationsFragment : } } - lifecycleScope.launchWhenResumed { - val useAbsoluteTime = preferences.getBoolean(PrefKeys.ABSOLUTE_TIME_VIEW, false) - while (!useAbsoluteTime) { - adapter.notifyItemRangeChanged(0, adapter.itemCount, listOf(StatusBaseViewHolder.Key.KEY_CREATED)) - delay(1.toDuration(DurationUnit.MINUTES)) + viewLifecycleOwner.lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.RESUMED) { + val useAbsoluteTime = preferences.getBoolean(PrefKeys.ABSOLUTE_TIME_VIEW, false) + while (!useAbsoluteTime) { + adapter.notifyItemRangeChanged( + 0, + adapter.itemCount, + listOf(StatusBaseViewHolder.Key.KEY_CREATED) + ) + delay(1.toDuration(DurationUnit.MINUTES)) + } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6cb54a410..84dc2b9d4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ androidx-core = "1.9.0" androidx-exifinterface = "1.3.6" androidx-fragment = "1.5.5" androidx-junit = "1.1.5" +androidx-lifecycle = "2.6.0" androidx-paging = "3.1.1" androidx-preference = "1.2.0" androidx-recyclerview = "1.2.1" @@ -33,7 +34,6 @@ glide-animation-plugin = "2.24.0" gson = "2.10.1" kotlin = "1.8.10" image-cropper = "4.3.2" -lifecycle = "2.5.1" material = "1.8.0" material-drawer = "8.4.5" material-typeface = "4.0.0.2-kotlin" @@ -75,10 +75,10 @@ androidx-emoji2-views-core = { module = "androidx.emoji2:emoji2-views", version. androidx-emoji2-view-helper = { module = "androidx.emoji2:emoji2-views-helper", version.ref = "emoji2" } androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "androidx-exifinterface" } androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" } -androidx-lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "lifecycle" } -androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" } -androidx-lifecycle-reactivestreams-ktx = { module = "androidx.lifecycle:lifecycle-reactivestreams-ktx", version.ref = "lifecycle" } -androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" } +androidx-lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "androidx-lifecycle" } +androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidx-lifecycle" } +androidx-lifecycle-reactivestreams-ktx = { module = "androidx.lifecycle:lifecycle-reactivestreams-ktx", version.ref = "androidx-lifecycle" } +androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } androidx-paging-runtime-ktx = { module = "androidx.paging:paging-runtime-ktx", version.ref = "androidx-paging" } androidx-preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "androidx-preference" } androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidx-room" }