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

Commit 2e9ee9f1 authored by Chiao Cheng's avatar Chiao Cheng
Browse files

Fix NPE when a view is traversed without a parent.

getViewsBelowOf() could be called on a view that has already been
removed from the view hieracrchy.

Bug: 6543741
Change-Id: Id986133598b986ea9ae66595e6adf07dc07ecfb0
parent a1fa4d5d
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -201,12 +201,16 @@ public class EditorAnimator {
    /**
     * Traverses up the view hierarchy and returns all views below this item. Stops
     * once a parent is not a vertical LinearLayout
     *
     * @return List of views that are below the given view. Empty list if parent of view is null.
     */
    private static List<View> getViewsBelowOf(View view) {
        final ViewGroup victimParent = (ViewGroup) view.getParent();
        final List<View> result = Lists.newArrayList();
        if (victimParent != null) {
            final int index = victimParent.indexOfChild(view);
            getViewsBelowOfRecursive(result, victimParent, index + 1);
        }
        return result;
    }