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

Commit 85e0a90d authored by Mark Renouf's avatar Mark Renouf
Browse files

BubbleData [3/n]: separate Bubble view inflation

Allow creating a Bubble and inflating views later. This will be
used to allow BubbleController to create the Bubble object, but
BubbleStackView manage views.

Bug: 123542488
Test: atest BubbleControllerTest
Change-Id: I7bfe608f48a244e03e63ee458069ae10c0d541c3
parent c78840c7
Loading
Loading
Loading
Loading
+35 −8
Original line number Diff line number Diff line
@@ -26,16 +26,41 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
 */
class Bubble {

    private final String mKey;
    private final BubbleExpandedView.OnBubbleBlockedListener mListener;

    private boolean mInflated;

    public BubbleView iconView;
    public BubbleExpandedView expandedView;
    public String key;
    public NotificationEntry entry;

    Bubble(NotificationEntry e, BubbleExpandedView.OnBubbleBlockedListener listener) {
        entry = e;
        mKey = e.key;
        mListener = listener;
    }

    /** @deprecated use the other constructor to defer View creation. */
    @Deprecated
    Bubble(NotificationEntry e, LayoutInflater inflater, BubbleStackView stackView,
            BubbleExpandedView.OnBubbleBlockedListener listener) {
        entry = e;
        key = entry.key;
        this(e, listener);
        inflate(inflater, stackView);
    }

    public String getKey() {
        return mKey;
    }

    boolean isInflated() {
        return mInflated;
    }

    void inflate(LayoutInflater inflater, BubbleStackView stackView) {
        if (mInflated) {
            return;
        }
        iconView = (BubbleView) inflater.inflate(
                R.layout.bubble_view, stackView, false /* attachToRoot */);
        iconView.setNotif(entry);
@@ -44,12 +69,14 @@ class Bubble {
                R.layout.bubble_expanded_view, stackView, false /* attachToRoot */);
        expandedView.setEntry(entry, stackView);

        expandedView.setOnBlockedListener(listener);
        expandedView.setOnBlockedListener(mListener);
        mInflated = true;
    }

    public void setEntry(NotificationEntry entry) {
        key = entry.key;
    void setEntry(NotificationEntry entry) {
        if (mInflated) {
            iconView.update(entry);
            expandedView.update(entry);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class BubbleData {
    }

    public void addBubble(Bubble b) {
        mBubbles.put(b.key, b);
        mBubbles.put(b.getKey(), b);
    }

    @Nullable