summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java73
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteListView.java13
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java5
-rw-r--r--src/com/android/dialer/list/SwipeHelper.java14
4 files changed, 65 insertions, 40 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 84bd4b484..9e8476062 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -15,6 +15,9 @@
*/
package com.android.dialer.list;
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
@@ -140,6 +143,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
mActivityScrollListener.onListFragmentScrollStateChange(scrollState);
+ mLastScrollState = scrollState;
}
}
@@ -182,6 +186,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
new ContactTileLoaderListener();
private final ScrollListener mScrollListener = new ScrollListener();
+ private int mLastScrollState = ListView.OnScrollListener.SCROLL_STATE_IDLE;
+
@Override
public void onAttach(Activity activity) {
if (DEBUG) Log.d(TAG, "onAttach()");
@@ -404,19 +410,42 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
if (mItemIdLeftMap.isEmpty()) {
return;
}
+ final AnimatorSet animSet = new AnimatorSet();
+ final ArrayList<Animator> animators = new ArrayList<Animator>();
for (int i = 0; i < list.size(); i++) {
final View child = row.getChildAt(i);
final ContactEntry entry = list.get(i);
final long itemId = mContactTileAdapter.getAdjustedItemId(entry.id);
if (containsId(idsInPlace, itemId)) {
- child.setAlpha(0.0f);
- child.animate().alpha(1.0f)
- .setDuration(mAnimationDuration)
- .start();
+ animators.add(ObjectAnimator.ofFloat(
+ child, "alpha", 0.0f, 1.0f));
break;
+ } else {
+ Integer startLeft = mItemIdLeftMap.get(itemId);
+ int left = child.getLeft();
+ if (startLeft != null) {
+ if (startLeft != left) {
+ int delta = startLeft - left;
+ if (DEBUG) {
+ Log.d(TAG, "Found itemId: " + itemId + " for tileview child " + i +
+ " Left: " + left +
+ " Delta: " + delta);
+ }
+ animators.add(ObjectAnimator.ofFloat(
+ child, "translationX", delta, 0.0f));
+ }
+ } else {
+ // In case the last square row is pushed up from the non-square section.
+ animators.add(ObjectAnimator.ofFloat(
+ child, "translationX", left, 0.0f));
+ }
}
}
+ if (animators.size() > 0) {
+ animSet.setDuration(mAnimationDuration).playTogether(animators);
+ animSet.start();
+ }
}
/*
@@ -424,7 +453,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
* animations will be performed instead.
*/
private void animateListView(final long... idsInPlace) {
- if (mItemIdTopMap.isEmpty()) {
+ if (mItemIdTopMap.isEmpty() ||
+ mLastScrollState == ListView.OnScrollListener.SCROLL_STATE_FLING) {
// Don't do animations if the database is being queried for the first time and
// the previous item offsets have not been cached, or the user hasn't done anything
// (dragging, swiping etc) that requires an animation.
@@ -437,6 +467,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
public boolean onPreDraw() {
observer.removeOnPreDrawListener(this);
final int firstVisiblePosition = mListView.getFirstVisiblePosition();
+ final AnimatorSet animSet = new AnimatorSet();
+ final ArrayList<Animator> animators = new ArrayList<Animator>();
for (int i = 0; i < mListView.getChildCount(); i++) {
final View child = mListView.getChildAt(i);
int position = firstVisiblePosition + i;
@@ -450,17 +482,12 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
final long itemId = mAdapter.getItemId(position);
if (containsId(idsInPlace, itemId)) {
- child.setAlpha(0.0f);
- child.animate().alpha(1.0f)
- .setDuration(mAnimationDuration)
- .start();
+ animators.add(ObjectAnimator.ofFloat(
+ child, "alpha", 0.0f, 1.0f));
+ break;
} else {
Integer startTop = mItemIdTopMap.get(itemId);
final int top = child.getTop();
- if (DEBUG) {
- Log.d(TAG, "Found itemId: " + itemId + " for listview child " + i +
- " Top: " + top);
- }
int delta = 0;
if (startTop != null) {
if (startTop != top) {
@@ -473,14 +500,30 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
int childHeight = child.getHeight() + mListView.getDividerHeight();
startTop = top + (i > 0 ? childHeight : -childHeight);
delta = startTop - top;
+ } else {
+ // In the case the first non-square row is pushed down
+ // from the square section.
+ animators.add(ObjectAnimator.ofFloat(
+ child, "translationX", -child.getWidth(), 0.0f));
+ }
+ if (DEBUG) {
+ Log.d(TAG, "Found itemId: " + itemId + " for listview child " + i +
+ " Top: " + top +
+ " Delta: " + delta);
}
if (delta != 0) {
- child.setTranslationY(delta);
- child.animate().setDuration(mAnimationDuration).translationY(0);
+ animators.add(ObjectAnimator.ofFloat(
+ child, "translationY", delta, 0.0f));
}
}
}
+
+ if (animators.size() > 0) {
+ animSet.setDuration(mAnimationDuration).playTogether(animators);
+ animSet.start();
+ }
+
mItemIdTopMap.clear();
mItemIdLeftMap.clear();
return true;
diff --git a/src/com/android/dialer/list/PhoneFavoriteListView.java b/src/com/android/dialer/list/PhoneFavoriteListView.java
index 04bbe6b08..4e0b8ff0e 100644
--- a/src/com/android/dialer/list/PhoneFavoriteListView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteListView.java
@@ -105,7 +105,8 @@ public class PhoneFavoriteListView extends ListView implements SwipeHelperCallba
private final AnimatorListenerAdapter mDragShadowOverAnimatorListener =
new AnimatorListenerAdapter() {
- private void recycleDragShadow() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
if (mDragShadowBitmap != null) {
mDragShadowBitmap.recycle();
mDragShadowBitmap = null;
@@ -113,16 +114,6 @@ public class PhoneFavoriteListView extends ListView implements SwipeHelperCallba
mDragShadowOverlay.setVisibility(GONE);
mDragShadowOverlay.setImageBitmap(null);
}
-
- @Override
- public void onAnimationCancel(Animator animation) {
- recycleDragShadow();
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- recycleDragShadow();
- }
};
public PhoneFavoriteListView(Context context) {
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 2e18118e1..2b232e869 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -407,7 +407,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
return mColumnCount * mMaxTiledRows;
}
- protected int getRowIndex(int entryIndex) {
+ public int getRowIndex(int entryIndex) {
if (entryIndex < mMaxTiledRows * mColumnCount) {
return entryIndex / mColumnCount;
} else {
@@ -593,11 +593,14 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
*/
private void markDropArea(int itemIndex) {
if (isIndexInBound(mDragEnteredEntryIndex) && isIndexInBound(itemIndex)) {
+ mDataSetChangedListener.cacheOffsetsForDatasetChange();
// Remove the old placeholder item and place the new placeholder item.
+ final int oldIndex = mDragEnteredEntryIndex;
mContactEntries.remove(mDragEnteredEntryIndex);
mDragEnteredEntryIndex = itemIndex;
mContactEntries.add(mDragEnteredEntryIndex, ContactEntry.BLANK_ENTRY);
ContactEntry.BLANK_ENTRY.id = mDraggedEntry.id;
+ mDataSetChangedListener.onDataSetChangedForAnimation();
notifyDataSetChanged();
}
}
diff --git a/src/com/android/dialer/list/SwipeHelper.java b/src/com/android/dialer/list/SwipeHelper.java
index ce46ec3eb..03300df42 100644
--- a/src/com/android/dialer/list/SwipeHelper.java
+++ b/src/com/android/dialer/list/SwipeHelper.java
@@ -337,24 +337,12 @@ public class SwipeHelper {
invalidateGlobalRegion(animView);
}
});
- anim.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
+ anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animView.setAlpha(mStartAlpha);
mCallback.onDragCancelled(mCurrView);
}
-
- @Override
- public void onAnimationCancel(Animator animation) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
});
anim.start();
}