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

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

Merge "Avoid calling the same on change listeners twice"

parents 67b9fc38 8dedb584
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -49,7 +49,25 @@ public interface AssociationStore {
    /**  Listener for any changes to {@link AssociationInfo}-s. */
    interface OnChangeListener {
        default void onAssociationChanged(
                @ChangeType int changeType, AssociationInfo association) {}
                @ChangeType int changeType, AssociationInfo association) {
            switch (changeType) {
                case CHANGE_TYPE_ADDED:
                    onAssociationAdded(association);
                    break;

                case CHANGE_TYPE_REMOVED:
                    onAssociationRemoved(association);
                    break;

                case CHANGE_TYPE_UPDATED_ADDRESS_CHANGED:
                    onAssociationUpdated(association, true);
                    break;

                case CHANGE_TYPE_UPDATED_ADDRESS_UNCHANGED:
                    onAssociationUpdated(association, false);
                    break;
            }
        }

        default void onAssociationAdded(AssociationInfo association) {}

+0 −18
Original line number Diff line number Diff line
@@ -263,24 +263,6 @@ class AssociationStoreImpl implements AssociationStore {
        synchronized (mListeners) {
            for (OnChangeListener listener : mListeners) {
                listener.onAssociationChanged(changeType, association);

                switch (changeType) {
                    case CHANGE_TYPE_ADDED:
                        listener.onAssociationAdded(association);
                        break;

                    case CHANGE_TYPE_REMOVED:
                        listener.onAssociationRemoved(association);
                        break;

                    case CHANGE_TYPE_UPDATED_ADDRESS_CHANGED:
                        listener.onAssociationUpdated(association, true);
                        break;

                    case CHANGE_TYPE_UPDATED_ADDRESS_UNCHANGED:
                        listener.onAssociationUpdated(association, false);
                        break;
                }
            }
        }
    }