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

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

Merge "BubbleData: Add notion of "pending bubbles" while the contents are being loaded"

parents 1461a469 9ec3796a
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -111,7 +111,10 @@ public class BubbleData {
    }

    private final Context mContext;
    /** Bubbles that are actively in the stack. */
    private final List<Bubble> mBubbles;
    /** Bubbles that are being loaded but haven't been added to the stack just yet. */
    private final List<Bubble> mPendingBubbles;
    private Bubble mSelectedBubble;
    private boolean mExpanded;
    private final int mMaxBubbles;
@@ -143,6 +146,7 @@ public class BubbleData {
    public BubbleData(Context context) {
        mContext = context;
        mBubbles = new ArrayList<>();
        mPendingBubbles = new ArrayList<>();
        mStateChange = new Update(mBubbles);
        mMaxBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_rendered);
    }
@@ -188,7 +192,15 @@ public class BubbleData {
    Bubble getOrCreateBubble(NotificationEntry entry) {
        Bubble bubble = getBubbleWithKey(entry.getKey());
        if (bubble == null) {
            // Check for it in pending
            for (int i = 0; i < mPendingBubbles.size(); i++) {
                Bubble b = mPendingBubbles.get(i);
                if (b.getKey().equals(entry.getKey())) {
                    return b;
                }
            }
            bubble = new Bubble(entry);
            mPendingBubbles.add(bubble);
        } else {
            bubble.setEntry(entry);
        }
@@ -204,7 +216,7 @@ public class BubbleData {
        if (DEBUG_BUBBLE_DATA) {
            Log.d(TAG, "notificationEntryUpdated: " + bubble);
        }

        mPendingBubbles.remove(bubble); // No longer pending once we're here
        Bubble prevBubble = getBubbleWithKey(bubble.getKey());
        suppressFlyout |= !shouldShowFlyout(bubble.getEntry());

@@ -377,6 +389,12 @@ public class BubbleData {
    }

    private void doRemove(String key, @DismissReason int reason) {
        //  If it was pending remove it
        for (int i = 0; i < mPendingBubbles.size(); i++) {
            if (mPendingBubbles.get(i).getKey().equals(key)) {
                mPendingBubbles.remove(mPendingBubbles.get(i));
            }
        }
        int indexToRemove = indexForKey(key);
        if (indexToRemove == -1) {
            return;