Reducing calls to onCreateViewHolder due to animating children.
Bug 21133230 Change-Id: Ib5be0766d1ea56976195e33526d7595a16672eef
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user