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

Commit 28c250d0 authored by Mark Renouf's avatar Mark Renouf
Browse files

Clean up ActivityView workaround for release

After ag/6377578 it is now safe to call release() on ActivityView
and detach it from the window without waiting. This removes the
hack which adds it to a temporary view while it is released.

Test: manually added and rapidly removed many bubbles, no crash
Change-Id: I21497c30e518c257a70fe494ecaf0a6f1af8ad21
parent f9aa3044
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.StatsLog;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -453,23 +452,14 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
    /**
     * Removes and releases an ActivityView if one was previously created for this bubble.
     */
    public void destroyActivityView(ViewGroup tmpParent) {
    public void destroyActivityView() {
        if (mActivityView == null) {
            return;
        }
        if (!mActivityViewReady) {
            // release not needed, never initialized?
            mActivityView = null;
            return;
        }
        // HACK: release() will crash if the view is not attached.
        if (!isAttachedToWindow()) {
            mActivityView.setVisibility(View.GONE);
            tmpParent.addView(this);
        }

        if (mActivityViewReady) {
            mActivityView.release();
        ((ViewGroup) getParent()).removeView(this);
        }
        removeView(mActivityView);
        mActivityView = null;
        mActivityViewReady = false;
    }
+2 −2
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ public class BubbleStackView extends FrameLayout {

        // Remove it from the views
        int removedIndex = mBubbleContainer.indexOfChild(b.iconView);
        b.expandedView.destroyActivityView(this /* tmpParent */);
        b.expandedView.destroyActivityView();
        mBubbleContainer.removeView(b.iconView);

        int bubbleCount = mBubbleContainer.getChildCount();
@@ -375,7 +375,7 @@ public class BubbleStackView extends FrameLayout {
    public void stackDismissed() {
        for (Bubble bubble : mBubbleData.getBubbles()) {
            bubble.entry.setBubbleDismissed(true);
            bubble.expandedView.destroyActivityView(this /* tmpParent */);
            bubble.expandedView.destroyActivityView();
        }
        mBubbleData.clear();
        collapseStack();