summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-05-27 22:24:22 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-27 22:24:22 +0000
commit839a81769ee9d183c4dd59fae47ab58d80098518 (patch)
tree95606b8b3584982e75e73f1c32cc21978d329e52
parent3936676967647c4e277bd50e09a27564f2307786 (diff)
parent7d6a2cc5758909d3ba959f3cc0b8771e444a3c27 (diff)
am 7d6a2cc5: Merge "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." into lmp-preview-dev
* commit '7d6a2cc5758909d3ba959f3cc0b8771e444a3c27': 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.
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java47
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java14
2 files changed, 28 insertions, 33 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 9906513f8..475262055 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -71,12 +71,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. */
@@ -283,9 +284,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;
+ }
+ }
}
};
@@ -825,17 +836,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;
}
@@ -858,7 +859,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.
@@ -878,15 +879,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 6cf6e4579..de0055085 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -671,13 +671,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();
@@ -689,10 +690,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;
}
}