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

Commit 38d07cba authored by Justin Weir's avatar Justin Weir Committed by Android (Google) Code Review
Browse files

Merge "Add method for adding expansion listener without firing event" into udc-dev

parents f0e955ec fb416ecf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ constructor(
    fun enable(onPanelInteraction: Runnable) {
        if (action == null) {
            action = Action(onPanelInteraction)
            shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged)
            shadeExpansionStateManager.addShadeExpansionListener(this::onPanelExpansionChanged)
        } else {
            Log.e(TAG, "Already enabled")
        }
+9 −1
Original line number Diff line number Diff line
@@ -54,12 +54,20 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
     * Listener will also be immediately notified with the current values.
     */
    fun addExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.add(listener)
        addShadeExpansionListener(listener)
        listener.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount)
        )
    }

    /**
     * Adds a listener that will be notified when the panel expansion fraction has changed.
     * @see #addExpansionListener
     */
    fun addShadeExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.add(listener)
    }

    /** Removes an expansion listener. */
    fun removeExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.remove(listener)