summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-03-05 15:49:29 -0800
committerYorke Lee <yorkelee@google.com>2014-03-06 11:30:07 -0800
commitf4c5826ac14df34c42b210def5c7c9c311691795 (patch)
tree7db99443c3ec4954a4df0b62e8255aefbc67e249
parent7d63a49bd5d0d374795329a864f6b62038072dbb (diff)
Fix contact tile horizontal animations when swiping shortcut card
Instead of using the contact tile's position in the listview to determine what kind of horizontal animations it should undergo, use its position in the contact tile adapter. This ensures that its position remains the same if the shortcut card is swiped away, but is still calculated correctly if its actual position within the contact tile adapter changes. Bug: 13341497 Change-Id: Ia5d4bad1e01a4e47a3fcd934dd580c76ca183a20
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java15
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java19
2 files changed, 13 insertions, 21 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 79dbe8c49..7b4ff9f9a 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -447,7 +447,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
if (itemViewType == PhoneFavoritesTileAdapter.ViewTypes.TOP) {
// This is a tiled row, so save horizontal offsets instead
saveHorizontalOffsets((ContactTileRow) child, (ArrayList<ContactEntry>)
- mAdapter.getItem(position), position);
+ mAdapter.getItem(position),
+ mAdapter.getAdjustedPositionInContactTileAdapter(position));
}
if (DEBUG) {
Log.d(TAG, "Saving itemId: " + itemId + " for listview child " + i + " Top: "
@@ -506,7 +507,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
int left = child.getLeft();
Integer startRow = mItemIdTopMap.get(itemId);
-
if (startRow != null) {
if (startRow > currentRow) {
// Item has shifted upwards to the previous row.
@@ -535,10 +535,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
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));
}
}
}
@@ -580,7 +576,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
// This is a tiled row, so perform horizontal animations instead
performHorizontalAnimations((ContactTileRow) child, (
ArrayList<ContactEntry>) mAdapter.getItem(position), idsInPlace,
- position);
+ mAdapter.getAdjustedPositionInContactTileAdapter(position));
}
final long itemId = mAdapter.getItemId(position);
@@ -610,11 +606,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
}
startTop = top + (i > 0 ? itemHeight : -itemHeight);
delta = startTop - top;
- } else {
- // In case the first non-square row is pushed down
- // from the square section.
- animators.add(ObjectAnimator.ofFloat(
- child, "alpha", 0.0f, 1.0f));
}
if (DEBUG) {
Log.d(TAG, "Found itemId: " + itemId + " for listview child " + i +
diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
index 7d5dba25e..e09fc7d41 100644
--- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
@@ -144,7 +144,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
}
}
// Set position to the position of the actual favorite contact in the favorites adapter
- position = getAdjustedFavoritePosition(position, callLogAdapterCount);
+ position = getAdjustedPositionInContactTileAdapter(position);
return mContactTileAdapter.getItem(position);
}
@@ -176,7 +176,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
} else if (position < (callLogAdapterCount + mContactTileAdapter.getCount() +
getTeaserViewCount() + 1)) {
return mContactTileAdapter.getItemId(
- getAdjustedFavoritePosition(position, callLogAdapterCount));
+ getAdjustedPositionInContactTileAdapter(position));
} else {
// Default fallback. We don't normally get here.
return FAVORITES_MENU_ITEM_ID;
@@ -216,7 +216,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
return mContactTileAdapter.getViewTypeCount() + 3;
} else if (position < getCount()) {
return mContactTileAdapter.getItemViewType(
- getAdjustedFavoritePosition(position, callLogAdapterCount));
+ getAdjustedPositionInContactTileAdapter(position));
} else {
// Catch-all - we shouldn't get here but if we do use the same as the favorites menu.
return mContactTileAdapter.getViewTypeCount() + 3;
@@ -269,7 +269,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
// Set position to the position of the actual favorite contact in the favorites adapter.
// Adjusts based on the presence of other views, such as the favorites menu.
- position = getAdjustedFavoritePosition(position, callLogAdapterCount);
+ position = getAdjustedPositionInContactTileAdapter(position);
// Favorites section
final View view = mContactTileAdapter.getView(position, convertView, parent);
@@ -296,18 +296,19 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
return mCallLogAdapter.isEnabled(position);
} else { // For favorites section
return mContactTileAdapter.isEnabled(
- getAdjustedFavoritePosition(position, callLogAdapterCount));
+ getAdjustedPositionInContactTileAdapter(position));
}
}
/**
- * Determines the index into the mContactTileAdapter for the current position.
+ * Given the current position in the merged adapter, return the index in the
+ * mContactTileAdapter this position corresponds to.
*
- * @param position current position in the overall adapter.
- * @param callLogAdapterCount number of entries in "last calls" list (ie 0 or 1).
+ * @param position current position in the overall (merged) adapter.
* @return position in the mContactTileAdapter.
*/
- private int getAdjustedFavoritePosition(int position, int callLogAdapterCount) {
+ public int getAdjustedPositionInContactTileAdapter(int position) {
+ final int callLogAdapterCount = mCallLogAdapter.getCount();
if (position - callLogAdapterCount > TILE_INTERACTION_TEASER_VIEW_POSITION &&
mTileInteractionTeaserView.getShouldDisplayInList()) {
return position - callLogAdapterCount - 2;