diff options
author | calderwoodra <calderwoodra@google.com> | 2017-07-11 17:59:54 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-07-13 13:58:57 -0700 |
commit | bae68675ed347b934fbbfbcd8238a229d57ef14f (patch) | |
tree | 0b92b6bcc012389d34e8d6bb5acf689e0ac92597 | |
parent | b3d73844bd131e6aa806ea44e00cd6c4cd715cda (diff) |
Fixed ArrayIndexOutOfBoundsException in Contacts Fragment.
If a user caused their activity to undergo several state changes rapidly, they
could get the contacts fragment into a state where it wouldn't have any
elements but still call onScrollChange. This would result in calls to
getFirstCompletelyVisibleItemPosition returning NO_POSITION (-1) and throw an
AIOOBE when attempting to get a row's header value.
Bug: 63594129
Test: manual.
PiperOrigin-RevId: 161610423
Change-Id: I0c53587a6499c42abe5e51b6ac2b4108c0971545
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactsFragment.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/java/com/android/dialer/contactsfragment/ContactsFragment.java b/java/com/android/dialer/contactsfragment/ContactsFragment.java index e62771837..41fa8f9c5 100644 --- a/java/com/android/dialer/contactsfragment/ContactsFragment.java +++ b/java/com/android/dialer/contactsfragment/ContactsFragment.java @@ -170,6 +170,10 @@ public class ContactsFragment extends Fragment fastScroller.updateContainerAndScrollBarPosition(recyclerView); int firstVisibleItem = manager.findFirstVisibleItemPosition(); int firstCompletelyVisible = manager.findFirstCompletelyVisibleItemPosition(); + if (firstCompletelyVisible == RecyclerView.NO_POSITION) { + // No items are visible, so there are no headers to update. + return; + } String anchoredHeaderString = adapter.getHeaderString(firstCompletelyVisible); // If the user swipes to the top of the list very quickly, there is some strange behavior |