Bug 1116415 - 9. Add animation for tabs panel grid removes. draft
authorTom Klein <twointofive@gmail.com>
Mon, 12 Sep 2016 11:03:32 -0500
changeset 418600 a49c91a6231a4be1e185def92674c4ffaa9c9b36
parent 418599 4bcb00cb8673ab141b50d990fd48e698d139a7d0
child 418601 e42331920234137c94218ad2b616f0f42132df76
push id30721
push userbmo:twointofive@gmail.com
push dateWed, 28 Sep 2016 19:14:00 +0000
bugs1116415
milestone52.0a1
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
mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
--- 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.