Bug 1314322 - Pre: Don't reset view attributes in onBindViewHolder. r?sebastian
MozReview-Commit-ID: 2IKi7dHADx9
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsLayoutRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsLayoutRecyclerAdapter.java
@@ -103,20 +103,19 @@ public class TabsLayoutRecyclerAdapter
return tabs.get(position);
}
@Override
public void onBindViewHolder(TabsListViewHolder viewHolder, int position) {
final Tab tab = getItem(position);
final TabsLayoutItemView itemView = (TabsLayoutItemView) viewHolder.itemView;
itemView.assignValues(tab);
- // Make sure we didn't miss any resets after animations and swipes:
- itemView.setAlpha(1);
- itemView.setTranslationX(0);
- itemView.setTranslationY(0);
+ // Be careful (re)setting position values here: bind is called on each notifyItemChanged,
+ // so you could be stomping on values that have been set in support of other animations
+ // that are already underway.
}
@Override
public TabsListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final TabsLayoutItemView viewItem = (TabsLayoutItemView) inflater.inflate(tabLayoutId, parent, false);
viewItem.setPrivateMode(isPrivate);
viewItem.setCloseOnClickListener(closeOnClickListener);
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
@@ -106,9 +106,18 @@ public class TabsListLayout extends Tabs
cascadeDelay += ANIMATION_CASCADE_DELAY;
}
}
@Override
protected boolean addAtIndexRequiresScroll(int index) {
return index == 0 || index == getAdapter().getItemCount() - 1;
}
+
+ @Override
+ public void onChildAttachedToWindow(View child) {
+ // Make sure we reset any attributes that may have been animated in this child's previous
+ // incarnation.
+ child.setTranslationX(0);
+ child.setTranslationY(0);
+ child.setAlpha(1);
+ }
}