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

Commit b6b9e69a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Add KeyedObservableDelegate and fix datastore binding issue" into main

parents 0943f96f d047696a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import java.util.concurrent.Executor
 * Adapter of [Handler] and [Executor], where the task is executed on handler with given looper.
 *
 * When current looper is same with the given looper, task passed to [Executor.execute] will be
 * executed immediately to improve better performance.
 * executed immediately to achieve better performance.
 *
 * @param looper Looper of the handler.
 */
+4 −0
Original line number Diff line number Diff line
@@ -114,6 +114,10 @@ interface KeyedObservable<K> {
    fun notifyChange(key: K, reason: Int)
}

/** Delegation of [KeyedObservable]. */
open class KeyedObservableDelegate<K>(delegate: KeyedObservable<K>) :
    KeyedObservable<K> by delegate

/** A thread safe implementation of [KeyedObservable]. */
open class KeyedDataObservable<K> : KeyedObservable<K> {
    // Instead of @GuardedBy("this"), guarded by itself because KeyedDataObservable object could be
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,8 @@ class PreferenceScreenBindingHelper(
                } else {
                    preferences[preference.key]?.let {
                        preferenceBindingFactory.bind(preference, it)
                        (it as? PersistentPreference<*>)?.storage(context)?.let { storage ->
                        val metadata = it.metadata
                        (metadata as? PersistentPreference<*>)?.storage(context)?.let { storage ->
                            preference.preferenceDataStore =
                                storages.getOrPut(storage) { PreferenceDataStoreAdapter(storage) }
                        }