Bug 1116415 - 9. Add animation for tabs panel grid removes.
Using 'animator.setChangeDuration(0);' in the grid layout causes some (depending
on recycling state?) removes to animate way too fast; we might as well change
to 'animator.setSupportsChangeAnimations(false);' in the linear layout case as
well since it's supported.
MozReview-Commit-ID: 35QpUIK8CEZ
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
@@ -5,16 +5,17 @@
package org.mozilla.gecko.tabs;
import org.mozilla.gecko.R;
import org.mozilla.gecko.widget.SpacingDecoration;
import android.content.Context;
import android.content.res.Resources;
+import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.AttributeSet;
public class TabsGridLayout extends TabsLayout {
public TabsGridLayout(Context context, AttributeSet attrs) {
super(context, attrs, R.layout.tabs_layout_item_view);
@@ -47,16 +48,24 @@ public class TabsGridLayout extends Tabs
final TabsTouchHelperCallback callback = new TabsTouchHelperCallback(this) {
@Override
protected float alphaForItemSwipeDx(float dX, int distanceToAlphaMin) {
return 1f - 2f * Math.abs(dX) / distanceToAlphaMin;
}
};
final ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(this);
+
+ final DefaultItemAnimator animator = new DefaultItemAnimator();
+ // On close we only animate the moves, not the remove.
+ animator.setRemoveDuration(0);
+ // A fade in/out each time the title/thumbnail/etc. gets updated isn't helpful, so disable
+ // the change animation.
+ animator.setSupportsChangeAnimations(false);
+ setItemAnimator(animator);
}
@Override
public void closeAll() {
autoHidePanel();
closeAllTabs();
}
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
@@ -43,17 +43,17 @@ public class TabsListLayout extends Tabs
};
final ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(this);
final TabsListLayoutAnimator animator = new TabsListLayoutAnimator();
animator.setRemoveDuration(ANIMATION_DURATION);
// A fade in/out each time the title/thumbnail/etc. gets updated isn't helpful, so disable
// the change animation.
- animator.setChangeDuration(0);
+ animator.setSupportsChangeAnimations(false);
setItemAnimator(animator);
}
@Override
public void closeAll() {
final int childCount = getChildCount();
// Just close the panel if there are no tabs to close.