diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyAdapter.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyAdapter.java index 08ef730d01..2f5d4758bf 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyAdapter.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyAdapter.java @@ -2,6 +2,7 @@ package com.airbnb.epoxy; import android.os.Bundle; +import android.support.annotation.CallSuper; import android.support.annotation.Nullable; import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; import android.support.v7.widget.RecyclerView; @@ -114,6 +115,7 @@ public int getItemCount() { return models.size(); } + public boolean isEmpty() { return models.isEmpty(); } @@ -166,6 +168,12 @@ protected void onModelBound(EpoxyViewHolder holder, EpoxyModel model, int pos } + @CallSuper + @Override + public boolean onFailedToRecycleView(EpoxyViewHolder holder) { + return holder.getModel().onFailedToRecycleView(); + } + protected BoundViewHolders getBoundViewHolders() { return boundViewHolders; } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index 02e76af95c..33f1ee2c51 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -1,7 +1,9 @@ package com.airbnb.epoxy; +import android.support.annotation.CallSuper; import android.support.annotation.LayoutRes; +import android.support.v7.widget.RecyclerView; import java.util.List; /** @@ -95,6 +97,16 @@ public final int getLayout() { return layout; } + /** + * Called when the view corresponding to this model failed to be recycled. This is left as a + * method stub since it is not always necessary to manually handle a failed recycle. + * @see EpoxyModel#onFailedToRecycleView() + */ + @CallSuper + protected boolean onFailedToRecycleView() { + return false; + } + /** * Sets fields of the model to default ones. */