Loading packages/SystemUI/unfold/src/com/android/systemui/unfold/updates/RotationChangeProvider.kt +6 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.atomic.AtomicInteger private const val INVALID_ROTATION = -1 /** * Allows to subscribe to rotation changes. Updates are provided for the display associated to Loading @@ -45,7 +48,7 @@ constructor( private val listeners = CopyOnWriteArrayList<RotationListener>() private val displayListener = RotationDisplayListener() private var lastRotation: Int? = null private val lastRotation = AtomicInteger(INVALID_ROTATION) override fun addCallback(listener: RotationListener) { bgHandler.post { Loading @@ -61,7 +64,7 @@ constructor( listeners -= listener if (listeners.isEmpty()) { unsubscribeToRotation() lastRotation = null lastRotation.set(INVALID_ROTATION) } } } Loading Loading @@ -100,9 +103,8 @@ constructor( if (displayId == display.displayId) { val currentRotation = display.rotation if (lastRotation == null || lastRotation != currentRotation) { if (lastRotation.compareAndSet(lastRotation.get(), currentRotation)) { listeners.forEach { it.onRotationChanged(currentRotation) } lastRotation = currentRotation } } } finally { Loading Loading
packages/SystemUI/unfold/src/com/android/systemui/unfold/updates/RotationChangeProvider.kt +6 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.atomic.AtomicInteger private const val INVALID_ROTATION = -1 /** * Allows to subscribe to rotation changes. Updates are provided for the display associated to Loading @@ -45,7 +48,7 @@ constructor( private val listeners = CopyOnWriteArrayList<RotationListener>() private val displayListener = RotationDisplayListener() private var lastRotation: Int? = null private val lastRotation = AtomicInteger(INVALID_ROTATION) override fun addCallback(listener: RotationListener) { bgHandler.post { Loading @@ -61,7 +64,7 @@ constructor( listeners -= listener if (listeners.isEmpty()) { unsubscribeToRotation() lastRotation = null lastRotation.set(INVALID_ROTATION) } } } Loading Loading @@ -100,9 +103,8 @@ constructor( if (displayId == display.displayId) { val currentRotation = display.rotation if (lastRotation == null || lastRotation != currentRotation) { if (lastRotation.compareAndSet(lastRotation.get(), currentRotation)) { listeners.forEach { it.onRotationChanged(currentRotation) } lastRotation = currentRotation } } } finally { Loading