Don't use View ID to search next focus backward View

There might be several Views with the same ID in View hierarchy,
and if we search the user specified next focused view by comparing
the View ID, it may return the wrong View with the same ID. To fix
that, we should compare the View itself.

Fixes: 147829061
Test: manual

Change-Id: I3eeb68ed3ea30ce9461165eea56227cb81b21929
This commit is contained in:
Yabin Huang
2020-01-16 13:32:59 -08:00
parent 794d53e7ff
commit ef8a8ac927

View File

@@ -12602,11 +12602,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
return findViewInsideOutShouldExist(root, mNextFocusForwardId);
case FOCUS_BACKWARD: {
if (mID == View.NO_ID) return null;
final int id = mID;
return root.findViewByPredicateInsideOut(this, new Predicate<View>() {
@Override
public boolean test(View t) {
return t.mNextFocusForwardId == id;
return t.findViewById(t.mNextFocusForwardId) == View.this;
}
});
}