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

Commit a61cab78 authored by Clark Scheff's avatar Clark Scheff
Browse files

Reduce memory leaks by removing all views.

Change-Id: I1c7d3647ae0d40aa214108ea22e007e3cb3191b9
parent 814f46b4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3222,6 +3222,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void recreateStatusBar() {
        mRecreating = true;
        mStatusBarContainer.removeAllViews();
        removeAllViews(mStatusBarWindow);

        // extract icons from the soon-to-be recreated viewgroup.
        int nIcons = mStatusIcons.getChildCount();
@@ -3268,6 +3269,17 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mRecreating = false;
    }

    private void removeAllViews(ViewGroup parent) {
        int N = parent.getChildCount();
        for (int i = 0; i < N; i++) {
            View child = parent.getChildAt(i);
            if (child instanceof ViewGroup) {
                removeAllViews((ViewGroup) child);
            }
        }
        parent.removeAllViews();
    }

    /**
     * Reload some of our resources when the configuration changes.
     *