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

Commit 24b59fca authored by Dave Mankoff's avatar Dave Mankoff Committed by Android (Google) Code Review
Browse files

Merge "Synchronize listeners in ConfigurationControllerImpl" into main

parents a348348d 349c46c4
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -59,7 +59,10 @@ class ConfigurationControllerImpl @Inject constructor(
    }

    override fun notifyThemeChanged() {
        val listeners = ArrayList(listeners)
        // Avoid concurrent modification exception
        val listeners = synchronized(this.listeners) {
           ArrayList(this.listeners)
        }

        listeners.filterForEach({ this.listeners.contains(it) }) {
            it.onThemeChanged()
@@ -68,8 +71,9 @@ class ConfigurationControllerImpl @Inject constructor(

    override fun onConfigurationChanged(newConfig: Configuration) {
        // Avoid concurrent modification exception
        val listeners = ArrayList(listeners)

        val listeners = synchronized(this.listeners) {
           ArrayList(this.listeners)
        }
        listeners.filterForEach({ this.listeners.contains(it) }) {
            it.onConfigChanged(newConfig)
        }
@@ -148,13 +152,17 @@ class ConfigurationControllerImpl @Inject constructor(
    }

    override fun addCallback(listener: ConfigurationListener) {
        synchronized(listeners) {
            listeners.add(listener)
        }
        listener.onDensityOrFontScaleChanged()
    }

    override fun removeCallback(listener: ConfigurationListener) {
        synchronized(listeners) {
            listeners.remove(listener)
        }
    }

    override fun isLayoutRtl(): Boolean {
        return layoutDirection == LAYOUT_DIRECTION_RTL