Reducing calls to onCreateViewHolder due to animating children.

Bug 21133230

Change-Id: Ib5be0766d1ea56976195e33526d7595a16672eef
This commit is contained in:
Winson Chung
2015-05-15 15:15:11 -07:00
parent 2a1580ca7d
commit 2d58471e8d
2 changed files with 10 additions and 0 deletions
@@ -118,6 +118,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
if (DEBUG) {
Log.d(TAG, "reset called on:" + mWidgetName.getText());
}
mWidgetImage.animate().cancel();
mWidgetImage.setImageDrawable(null);
mWidgetName.setText(null);
mWidgetDims.setText(null);
@@ -185,6 +185,15 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
}
}
@Override
public boolean onFailedToRecycleView(WidgetsRowViewHolder holder) {
// If child views are animating, then the RecyclerView may choose not to recycle the view,
// causing extraneous onCreateViewHolder() calls. It is safe in this case to continue
// recycling this view, and take care in onViewRecycled() to cancel any existing
// animations.
return true;
}
@Override
public long getItemId(int pos) {
return pos;