Merge "Refine animation to remove strange reshuffling animation"

This commit is contained in:
Lei Yu
2017-01-03 21:05:47 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 5 deletions

View File

@@ -18,15 +18,22 @@ package com.android.settings.dashboard;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView.ViewHolder;
import com.android.settingslib.drawer.Tile;
public class DashboardItemAnimator extends DefaultItemAnimator {
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY,
int toX, int toY) {
if (oldHolder == newHolder) {
fromX += ViewCompat.getTranslationX(oldHolder.itemView);
fromY += ViewCompat.getTranslationY(oldHolder.itemView);
final Object tag = oldHolder.itemView.getTag();
if (tag instanceof Tile && oldHolder == newHolder) {
// When this view has other move animation running, skip this value to avoid
// animations interrupt each other.
if (!isRunning()) {
fromX += ViewCompat.getTranslationX(oldHolder.itemView);
fromY += ViewCompat.getTranslationY(oldHolder.itemView);
}
if (fromX == toX && fromY == toY) {
dispatchMoveFinished(oldHolder);
return false;

View File

@@ -263,6 +263,7 @@ public class DashboardSummary extends InstrumentedPreferenceFragment
public void onConditionsChanged() {
Log.d(TAG, "onConditionsChanged");
mAdapter.setConditions(mConditionManager.getConditions());
mDashboard.scrollToPosition(0);
}
private class SuggestionLoader extends AsyncTask<Void, Void, List<Tile>> {