BubbleData [2/n]: adds Listener interface
This change introduces an interface which BubbleData will use to report changes to the state of bubbles on-screen. This will allow BubbleData to implement and propagate ordering and grouping changes. Bug: 123542488 Test: atest BubbleControllerTest Change-Id: I35708c45e23fed4369605eecd986cdff96e23d34
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user