-
Notifications
You must be signed in to change notification settings - Fork 183
Steps for migration to 3.0
Step 1: Before updating to v3.0.0 - Migrate from deprecated ViewRenderer
to ViewBinder
Step 1: Before updating to v3.0.0 - Remove any using context
-new RendererRecyclerViewAdapter(getContext())
+new RendererRecyclerViewAdapter()
Step 2: Update version of RendererRecyclerViewAdapter to v3.0.0
Step 3: Replace ViewBinder
name to ViewRenderer
name, add Generic types where it is need
-ViewBinder<>
+ViewRenderer<YourModel, ViewFinder>
Step 4: Fix imports
-import com.github.vivchar.rendererrecyclerviewadapter.binder.ViewBinder
-import com.github.vivchar.rendererrecyclerviewadapter.binder.ViewFinder
-import com.github.vivchar.rendererrecyclerviewadapter.binder.ViewFinderFactory
-import com.github.vivchar.rendererrecyclerviewadapter.binder.ViewProvider;
+import com.github.vivchar.rendererrecyclerviewadapter.ViewFinder
+import com.github.vivchar.rendererrecyclerviewadapter.ViewFinderFactory
+import com.github.vivchar.rendererrecyclerviewadapter.ViewProvider;
Step 5: Add second generic type where it is need
===TODO
Step 1: Replace DiffCallback
to DefaultDiffCallback
public class YourDiffCallback
- extends DiffCallback<ViewModel> {
+ extends DefaultDiffCallback<ViewModel> {
- public boolean areContentsTheSame(ViewModel oldItemPosition, ViewModel newItemPosition) {
- return oldItemPosition.equals(newItemPosition);
- }
- public Object getChangePayload(int oldItemPosition, int newItemPosition) {
- final ViewModel newItem = mNewItems.get(newItemPosition);
- final ViewModel oldItem = mOldItems.get(oldItemPosition);
-
+ public Object getChangePayload(ViewModel oldItem, ViewModel newItem) {
//your code
- return super.getChangePayload(oldItemPosition, newItemPosition);
+ return super.getChangePayload(oldItem, newItem);
}
}
Step 2: If you override createCompositeViewHolder
method, replace to createViewHolder
- protected CompositeViewHolder<VF> createCompositeViewHolder(ViewGroup parent) {
+ public CompositeViewHolder<VF> createViewHolder(ViewGroup parent) {
}
Step 4: Migrate to ViewBinder
, old deprecated ViewRenderer
was removed, please also note that ViewBinder
was renamed to ViewRender
, so you should migrate from old deprecated ViewRenderer
to new ViewRenderer
Here is the doc How to use new ViewRenderer
- mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
+ mRecyclerViewAdapter.registerRenderer(new ViewRenderer<>(
Step 5: Rework deprecated ViewRenderer
to new ViewRender
(ViewBinder)
FYI: old deprecated ViewRender
was removed, but ViewBinder
was renamed to ViewRender
- mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
+ mRecyclerViewAdapter.registerRenderer(new ViewRenderer<>(
Step 6: If you use ViewState
you should implement new interface
public interface ViewState<VH extends RecyclerView.ViewHolder> {
+ void clear(@NonNull VH holder);
+ void save(@NonNull VH holder);
void restore(@NonNull VH holder);
}
public interface ViewStateProvider<M extends ViewModel, VH extends ViewHolder> {
- ViewState createViewState(@NonNull VH holder);
+ ViewState createViewState();
int createViewStateID(@NonNull M model);
}