Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0094eb8f authored by Yorke Lee's avatar Yorke Lee Committed by Android (Google) Code Review
Browse files

Merge "Fix contact tile horizontal animations when swiping shortcut card DO NOT MERGE" into klp-dev

parents a1d699ba 958a3b6e
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -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 +
+10 −9
Original line number Diff line number Diff line
@@ -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;