From fa15094f656599b24e1c2a5d59ca1d8c0e515d10 Mon Sep 17 00:00:00 2001 From: Ta-wei Yen Date: Wed, 16 Mar 2016 12:32:49 -0700 Subject: Prevent incorrect call log item from expanding when new item arrives mCurrentlyExpandedPosition is unreliable when the list is changing, use mCurrentlyExpandedRowId to determine which item is expanded instead. Positions stored in CallLogAdaptor are also invalidated when the list is changing. Bug:25283769 Change-Id: Iffca8c7d65933cfcdd12f2f3cc85170226db1c4a --- src/com/android/dialer/calllog/CallLogAdapter.java | 13 +++++++++++-- src/com/android/dialer/calllog/CallLogFragment.java | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index dfb5190e1..165594efa 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -595,9 +595,10 @@ public class CallLogAdapter extends GroupingListAdapter // In case ViewHolders were added/removed, update the expanded position if the rowIds // match so that we can restore the correct expanded state on rebind. mCurrentlyExpandedPosition = position; + views.showActions(true); + } else { + views.showActions(false); } - - views.showActions(mCurrentlyExpandedPosition == position); views.updatePhoto(); mCallLogListItemHelper.setPhoneCallDetails(views, details); @@ -683,6 +684,14 @@ public class CallLogAdapter extends GroupingListAdapter mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; } + /** + * When the list is changing all stored position is no longer valid. + */ + public void invalidatePositions() { + mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; + mHiddenPosition = RecyclerView.NO_POSITION; + } + /** * When the user clicks "undo", the hidden item is unhidden. */ diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 07299a2fb..67b72a5a3 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -217,6 +217,7 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis // Return false; we did not take ownership of the cursor return false; } + mAdapter.invalidatePositions(); mAdapter.setLoading(false); mAdapter.changeCursor(cursor); // This will update the state of the "Clear call log" menu item. -- cgit v1.2.3