Bug 895549 - Only remove transforms when we're about to recycle a view. r=lucasr
authorWes Johnston <wjohnston@mozilla.com>
Fri, 26 Jul 2013 09:24:51 -0700
changeset 140174 f8d184e3879d
parent 140173 bff7e921c95d
child 140175 79f46ef38047
push id25016
push userryanvm@gmail.com
push dateSat, 27 Jul 2013 02:25:56 +0000
treeherdermozilla-central@fb48c7d58b8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs895549
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 895549 - Only remove transforms when we're about to recycle a view. r=lucasr
mobile/android/base/TabsTray.java
--- a/mobile/android/base/TabsTray.java
+++ b/mobile/android/base/TabsTray.java
@@ -44,16 +44,17 @@ public class TabsTray extends TwoWayView
     private int mCloseAnimationCount;
 
     private TabSwipeGestureListener mSwipeListener;
 
     // Time to animate non-flinged tabs of screen, in milliseconds
     private static final int ANIMATION_DURATION = 250;
 
     private static final String ABOUT_HOME = "about:home";
+    private int mOriginalSize = 0;
 
     public TabsTray(Context context, AttributeSet attrs) {
         super(context, attrs);
         mContext = context;
 
         mCloseAnimationCount = 0;
         mPendingClosedTabs = new ArrayList<View>();
 
@@ -256,27 +257,44 @@ public class TabsTray extends TwoWayView
                 row.thumbnail.setImageResource(R.drawable.abouthome_thumbnail);
             else
                 row.thumbnail.setImageResource(R.drawable.tab_thumbnail_default);
 
             row.title.setText(tab.getDisplayTitle());
             row.close.setTag(row);
         }
 
+        private void resetTransforms(View view) {
+            ViewHelper.setAlpha(view, 1);
+            if (mOriginalSize == 0)
+                return;
+
+            if (isVertical()) {
+                ViewHelper.setHeight(view, mOriginalSize);
+                ViewHelper.setTranslationX(view, 0);
+            } else {
+                ViewHelper.setWidth(view, mOriginalSize);
+                ViewHelper.setTranslationY(view, 0);
+            }
+        }
+
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
             TabRow row;
 
             if (convertView == null) {
                 convertView = mInflater.inflate(R.layout.tabs_row, null);
                 row = new TabRow(convertView);
                 row.close.setOnClickListener(mOnCloseClickListener);
                 convertView.setTag(row);
             } else {
                 row = (TabRow) convertView.getTag();
+                // If we're recycling this view, there's a chance it was transformed during
+                // the close animation. Remove any of those properties.
+                resetTransforms(convertView);
             }
 
             Tab tab = mTabs.get(position);
             assignValues(row, tab);
 
             return convertView;
         }
     }
@@ -326,33 +344,25 @@ public class TabsTray extends TwoWayView
         final boolean isVertical = isVertical();
         if (isVertical)
             animator.attach(view, Property.HEIGHT, 1);
         else
             animator.attach(view, Property.WIDTH, 1);
 
         TabRow tab = (TabRow)view.getTag();
         final int tabId = tab.id;
-        final int originalSize = (isVertical ? view.getHeight() : view.getWidth());
+        // Caching this assumes that all rows are the same height
+	if (mOriginalSize == 0)
+            mOriginalSize = (isVertical ? view.getHeight() : view.getWidth());
 
         animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
             @Override
             public void onPropertyAnimationStart() { }
             @Override
             public void onPropertyAnimationEnd() {
-                ViewHelper.setAlpha(view, 1);
-
-                if (isVertical) {
-                    ViewHelper.setHeight(view, originalSize);
-                    ViewHelper.setTranslationX(view, 0);
-                } else {
-                    ViewHelper.setWidth(view, originalSize);
-                    ViewHelper.setTranslationY(view, 0);
-                }
-
                 Tabs tabs = Tabs.getInstance();
                 Tab tab = tabs.getTab(tabId);
                 tabs.closeTab(tab);
             }
         });
 
         animator.start();
     }