From 3b4c4f350b485a0a107f7b9c412df9c2f1979d18 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 20 Dec 2021 22:01:06 +0100 Subject: [PATCH] move viewCoroutineScope to LifecycleExtensions.kt --- .../crazylegend/setofusefulkotlinextensions/nav/MVIFragment.kt | 2 +- .../main/java/com/crazylegend/fragment/FragmentExtensions.kt | 2 -- .../main/java/com/crazylegend/lifecycle/LifecycleExtensions.kt | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/nav/MVIFragment.kt b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/nav/MVIFragment.kt index 58f6276b2..040807739 100644 --- a/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/nav/MVIFragment.kt +++ b/app/src/main/java/com/crazylegend/setofusefulkotlinextensions/nav/MVIFragment.kt @@ -8,9 +8,9 @@ import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.crazylegend.common.ifTrue -import com.crazylegend.fragment.viewCoroutineScope import com.crazylegend.internetdetector.InternetDetector import com.crazylegend.lifecycle.repeatingJobOnStarted +import com.crazylegend.lifecycle.viewCoroutineScope import com.crazylegend.retrofit.apiresult.* import com.crazylegend.retrofit.throwables.isNoConnectionException import com.crazylegend.retrofit.viewstate.* diff --git a/fragment/src/main/java/com/crazylegend/fragment/FragmentExtensions.kt b/fragment/src/main/java/com/crazylegend/fragment/FragmentExtensions.kt index 4b9c38a18..ae0638e8d 100644 --- a/fragment/src/main/java/com/crazylegend/fragment/FragmentExtensions.kt +++ b/fragment/src/main/java/com/crazylegend/fragment/FragmentExtensions.kt @@ -670,8 +670,6 @@ fun Fragment.hasPipPermission(): Boolean { } } -val Fragment.viewCoroutineScope get() = viewLifecycleOwner.lifecycle.coroutineScope - inline fun Fragment.onViewDestroyed(crossinline action: () -> Unit) { observeLifecycleOwnerThroughLifecycleCreation { lifecycle.addObserver(object : DefaultLifecycleObserver { diff --git a/lifecycle/src/main/java/com/crazylegend/lifecycle/LifecycleExtensions.kt b/lifecycle/src/main/java/com/crazylegend/lifecycle/LifecycleExtensions.kt index b1b99f4d1..8facff06b 100644 --- a/lifecycle/src/main/java/com/crazylegend/lifecycle/LifecycleExtensions.kt +++ b/lifecycle/src/main/java/com/crazylegend/lifecycle/LifecycleExtensions.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry +import androidx.lifecycle.coroutineScope import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import kotlinx.coroutines.CoroutineScope @@ -76,3 +77,5 @@ fun Lifecycle.doOnEvent(which: Lifecycle.Event, block: () -> Unit) { addObserver(observer) } + +val Fragment.viewCoroutineScope get() = viewLifecycleOwner.lifecycle.coroutineScope