diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-19 19:15:59 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-06-23 17:41:11 -0700 |
commit | 158dfa2dcb89db772f61af6f1f6775fcf5695e60 (patch) | |
tree | b2e1d3739dbdf50e4aec3eaa1c0680efcd2bf635 /src | |
parent | af7d8bbd51a315a500796d397a28afecc2358d1e (diff) |
Expand the first call log item for new cursors.
This increases discoverability of the expand actions, and also
makes it quicker to interact with the most recent items.
Bug: 21960523
Change-Id: I6aefdd5b96a86177b26ecc59879d1a787115221a
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 4304002da..28ca8f941 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -79,6 +79,8 @@ public class CallLogAdapter extends GroupingListAdapter // Tracks the rowId of the currently expanded list item, so the position can be updated if there // are any changes to the call log entries, such as additions or removals. private long mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; + // Whether the first call log list item has been automatically expanded for a new cursor. + private boolean mHasBoundFirstView; /** * Hashmap, keyed by call Id, used to track the day group for a call. As call log entries are @@ -233,6 +235,16 @@ public class CallLogAdapter extends GroupingListAdapter mCallFetcher.fetchCalls(); } + @Override + public void changeCursor(Cursor cursor) { + // Data has changed; reset so that the first call log list item will be expanded. + mHasBoundFirstView = false; + mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; + mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; + + super.changeCursor(cursor); + } + public void setLoading(boolean loading) { mLoading = loading; } @@ -400,10 +412,15 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details); - // Update the expanded position if the rowIds match, in case ViewHolders were added/removed. - // Then restore the state of the row on rebind. if (mCurrentlyExpandedRowId == views.rowId) { + // 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; + } else if (!mHasBoundFirstView) { + // Expand the first view when loading the call log to expose the actions. + mCurrentlyExpandedRowId = views.rowId; mCurrentlyExpandedPosition = position; + mHasBoundFirstView = true; } views.showActions(mCurrentlyExpandedPosition == position); |