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

Commit bd1d652f authored by Alan Viverette's avatar Alan Viverette Committed by Android Git Automerger
Browse files

am 8d8c53df: am 76c73ae4: am 12874d2d: am b9b57225: am 95137857: Merge "Avoid...

am 8d8c53df: am 76c73ae4: am 12874d2d: am b9b57225: am 95137857: Merge "Avoid NPE when getPositionForView() is called on detached view" into mnc-dev

* commit '8d8c53df':
  Avoid NPE when getPositionForView() is called on detached view
parents 0fdf3fc6 8d8c53df
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -612,7 +612,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
        View listItem = view;
        try {
            View v;
            while (!(v = (View) listItem.getParent()).equals(this)) {
            while ((v = (View) listItem.getParent()) != null && !v.equals(this)) {
                listItem = v;
            }
        } catch (ClassCastException e) {
@@ -620,6 +620,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
            return INVALID_POSITION;
        }

        if (listItem != null) {
            // Search the children for the list item
            final int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
@@ -627,6 +628,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
                    return mFirstPosition + i;
                }
            }
        }

        // Child not found!
        return INVALID_POSITION;