From 68e771378889a479a80aac29a9ec2136b7ef27b6 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 23 May 2014 11:25:55 -0700 Subject: Changing the call log collapse animation for previous item so it happens at the same time as the expansion of another row; this eliminates the need for calling notifyDataSetChanged on expand/collapse. Bug: 13962594 Change-Id: I8f67de49c7cc6382acb0fd26e887d4cdc8e5d6e3 --- src/com/android/dialer/calllog/CallLogAdapter.java | 47 +++++++++------------- .../android/dialer/calllog/CallLogFragment.java | 14 ++++--- 2 files changed, 28 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 12d5531fd..583f10b7f 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -75,12 +75,13 @@ public class CallLogAdapter extends GroupingListAdapter public void onItemExpanded(CallLogListItemView view); /** - * Determines whether a call log entry with a given ID is currently visible in the ListView. + * Retrieves the call log view for the specified call Id. If the view is not currently + * visible, returns null. * - * @param callId The call ID to check. - * @return True if the call log entry with the given ID is visible. + * @param callId The call Id. + * @return The call log view. */ - public boolean isItemVisible(long callId); + public CallLogListItemView getViewForCallId(long callId); } /** Interface used to initiate a refresh of the content. */ @@ -290,9 +291,19 @@ public class CallLogAdapter extends GroupingListAdapter // Animate the expansion or collapse. if (mCallItemExpandedListener != null) { mCallItemExpandedListener.onItemExpanded(callLogItem); - } - notifyDataSetChanged(); + // Animate the collapse of the previous item if it is still visible on screen. + if (mPreviouslyExpanded != NONE_EXPANDED) { + CallLogListItemView previousItem = mCallItemExpandedListener.getViewForCallId( + mPreviouslyExpanded); + + if (previousItem != null) { + expandOrCollapseActions(previousItem, false); + mCallItemExpandedListener.onItemExpanded(previousItem); + } + mPreviouslyExpanded = NONE_EXPANDED; + } + } } }; @@ -832,17 +843,7 @@ public class CallLogAdapter extends GroupingListAdapter } else { // Expanding a row (collapsing current expanded one). - // Where an item which was previously expanded is still on screen, track it as being - // previously expanded so that we will animate the collapse on re-bind. - if (mCurrentlyExpanded != NONE_EXPANDED && - mCallItemExpandedListener != null && - mCallItemExpandedListener.isItemVisible(mCurrentlyExpanded)) { - - mPreviouslyExpanded = mCurrentlyExpanded; - } else { - // Item is no longer on screen, so we will not animate its collapse on rebind. - mPreviouslyExpanded = NONE_EXPANDED; - } + mPreviouslyExpanded = mCurrentlyExpanded; mCurrentlyExpanded = rowId; return true; } @@ -865,7 +866,7 @@ public class CallLogAdapter extends GroupingListAdapter views.actionsView.setAlpha(1.0f); views.callLogEntryView.setBackgroundColor( callLogItem.getResources().getColor(R.color.background_dialer_light)); - views.callLogEntryView.setTranslationZ(callLogItem.getResources().getDimension( + callLogItem.setTranslationZ(callLogItem.getResources().getDimension( R.dimen.call_log_expanded_translation_z)); // Attempt to give accessibility focus to one of the action buttons. @@ -885,15 +886,7 @@ public class CallLogAdapter extends GroupingListAdapter views.callLogEntryView.setBackgroundColor( callLogItem.getResources().getColor(R.color.background_dialer_list_items)); - views.callLogEntryView.setElevation(0); - - // Where the current row was previously expanded, trigger a collapse animation. - if (views.rowId == mPreviouslyExpanded) { - if (mCallItemExpandedListener != null && views.actionsView != null) { - mCallItemExpandedListener.onItemExpanded(callLogItem); - } - mPreviouslyExpanded = NONE_EXPANDED; - } + callLogItem.setTranslationZ(0); } } diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 240de8531..faa4a3e64 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -668,13 +668,14 @@ public class CallLogFragment extends ListFragment } /** - * Determines whether a call log entry with a given ID is currently visible in the list view. + * Retrieves the call log view for the specified call Id. If the view is not currently + * visible, returns null. * - * @param callId The call ID to check. - * @return True if the call log entry with the given ID is visible. + * @param callId The call Id. + * @return The call log view. */ @Override - public boolean isItemVisible(long callId) { + public CallLogListItemView getViewForCallId(long callId) { ListView listView = getListView(); int firstPosition = listView.getFirstVisiblePosition(); @@ -686,10 +687,11 @@ public class CallLogFragment extends ListFragment if (view != null) { final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); if (viewHolder != null && viewHolder.rowId == callId) { - return true; + return (CallLogListItemView)view; } } } - return false; + + return null; } } -- cgit v1.2.3