Merge "BubbleData [2/n]: adds Listener interface" into qt-dev

This commit is contained in:
Mark Renouf
2019-04-08 19:15:03 +00:00
committed by Android (Google) Code Review
2 changed files with 101 additions and 0 deletions

View File

@@ -216,6 +216,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
}
mBubbleData = data;
mBubbleData.setListener(mBubbleDataListener);
mSurfaceSynchronizer = synchronizer;
}
@@ -438,6 +439,47 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
}
};
private final BubbleData.Listener mBubbleDataListener = new BubbleData.Listener() {
@Override
public void onBubbleAdded(Bubble bubble) {
}
@Override
public void onBubbleRemoved(Bubble bubble, int reason) {
}
public void onBubbleUpdated(Bubble bubble) {
}
@Override
public void onOrderChanged(List<Bubble> bubbles) {
}
@Override
public void onSelectionChanged(Bubble selectedBubble) {
}
@Override
public void onExpandedChanged(boolean expanded) {
}
@Override
public void showFlyoutText(Bubble bubble, String text) {
}
@Override
public void apply() {
}
};
/**
* Lets any listeners know if bubble state has changed.
*/

View File

@@ -22,6 +22,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -32,7 +33,61 @@ import javax.inject.Singleton;
@Singleton
public class BubbleData {
/**
* This interface reports changes to the state and appearance of bubbles which should be applied
* as necessary to the UI.
* <p>
* Each operation is a report of a pending operation. Each should be considered in
* combination, when {@link #apply()} is called. For example, both: onExpansionChanged,
* and onOrderChanged
*/
interface Listener {
/**
* A new Bubble has been added. A call to {@link #onOrderChanged(List)} will
* follow, including the new Bubble in position
*/
void onBubbleAdded(Bubble bubble);
/**
* A Bubble has been removed. A call to {@link #onOrderChanged(List)} will
* follow.
*/
void onBubbleRemoved(Bubble bubble, @BubbleController.DismissReason int reason);
/**
* An existing bubble has been updated.
*
* @param bubble the bubble which was updated
*/
void onBubbleUpdated(Bubble bubble);
/**
* Indicates that one or more bubbles should change position. This may be result of insert,
* or removal of a Bubble, in addition to re-sorting existing Bubbles.
*
* @param bubbles an immutable list of the bubbles in the new order
*/
void onOrderChanged(List<Bubble> bubbles);
/** Indicates the selected bubble changed. */
void onSelectionChanged(Bubble selectedBubble);
/**
* The UI should transition to the given state, incorporating any pending changes during
* the animation.
*/
void onExpandedChanged(boolean expanded);
/** Flyout text should animate in, showing the given text. */
void showFlyoutText(Bubble bubble, String text);
/** Commit any pending operations (since last call of apply()) */
void apply();
}
private HashMap<String, Bubble> mBubbles = new HashMap<>();
private Listener mListener;
@VisibleForTesting
@Inject
@@ -69,4 +124,8 @@ public class BubbleData {
public void clear() {
mBubbles.clear();
}
public void setListener(Listener listener) {
mListener = listener;
}
}