Loading packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceStateProviders.kt +9 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.content.Context import android.content.ContextWrapper import android.content.Intent import android.os.Bundle import androidx.lifecycle.LifecycleCoroutineScope import kotlinx.coroutines.CoroutineScope /** * Interface to provide dynamic preference title. Loading Loading @@ -138,6 +140,13 @@ interface PreferenceLifecycleProvider { */ abstract class PreferenceLifecycleContext(context: Context) : ContextWrapper(context) { /** * [CoroutineScope] tied to the lifecycle, which is cancelled when the lifecycle is destroyed. * * @see [androidx.lifecycle.lifecycleScope] */ abstract val lifecycleScope: LifecycleCoroutineScope /** Returns the preference widget object associated with given key. */ abstract fun <T> findPreference(key: String): T? Loading packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.settingslib.preference import android.content.Context import android.content.Intent import android.os.Bundle import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceDataStore import androidx.preference.PreferenceGroup Loading Loading @@ -57,6 +59,9 @@ class PreferenceScreenBindingHelper( private val preferenceLifecycleContext = object : PreferenceLifecycleContext(context) { override val lifecycleScope: LifecycleCoroutineScope get() = fragment.lifecycleScope override fun <T> findPreference(key: String) = preferenceScreen.findPreference(key) as T? Loading Loading
packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceStateProviders.kt +9 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.content.Context import android.content.ContextWrapper import android.content.Intent import android.os.Bundle import androidx.lifecycle.LifecycleCoroutineScope import kotlinx.coroutines.CoroutineScope /** * Interface to provide dynamic preference title. Loading Loading @@ -138,6 +140,13 @@ interface PreferenceLifecycleProvider { */ abstract class PreferenceLifecycleContext(context: Context) : ContextWrapper(context) { /** * [CoroutineScope] tied to the lifecycle, which is cancelled when the lifecycle is destroyed. * * @see [androidx.lifecycle.lifecycleScope] */ abstract val lifecycleScope: LifecycleCoroutineScope /** Returns the preference widget object associated with given key. */ abstract fun <T> findPreference(key: String): T? Loading
packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.settingslib.preference import android.content.Context import android.content.Intent import android.os.Bundle import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceDataStore import androidx.preference.PreferenceGroup Loading Loading @@ -57,6 +59,9 @@ class PreferenceScreenBindingHelper( private val preferenceLifecycleContext = object : PreferenceLifecycleContext(context) { override val lifecycleScope: LifecycleCoroutineScope get() = fragment.lifecycleScope override fun <T> findPreference(key: String) = preferenceScreen.findPreference(key) as T? Loading