Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c88ab56a authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Introduce PreferenceLifecycleContext.lifecycleOwner

Bug: 332201912
Flag: EXEMPT library
Test: N/A
Change-Id: I7039224f51a230db2a3e3670d097a6daeaeda6d8
parent b8def990
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContract
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LifecycleOwner
import com.android.settingslib.datastore.KeyValueStore
import kotlinx.coroutines.CoroutineScope

@@ -247,6 +248,9 @@ interface PreferenceLifecycleProvider {
 */
abstract class PreferenceLifecycleContext(context: Context) : ContextWrapper(context) {

    /** Returns the fragment [LifecycleOwner]. */
    abstract val lifecycleOwner: LifecycleOwner

    /**
     * [CoroutineScope] tied to the lifecycle, which is cancelled when the lifecycle is destroyed.
     *
+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ class PreferenceScreenBindingHelper(

    internal val preferenceLifecycleContext =
        object : PreferenceLifecycleContext(fragment.requireContext()) {
            override val lifecycleOwner
                get() = fragment

            override val lifecycleScope
                get() = coroutineScope