Commit 29235d30 authored by Yusuke Iwaki's avatar Yusuke Iwaki

add default implementation for RealmModelListAdapter#getListUpdateCallback

parent baec51e3
...@@ -44,7 +44,7 @@ public abstract class ExtRealmModelListAdapter<T extends RealmObject, VM, ...@@ -44,7 +44,7 @@ public abstract class ExtRealmModelListAdapter<T extends RealmObject, VM,
this.updateListener = updateListener; this.updateListener = updateListener;
} }
protected ListUpdateCallback listUpdateCallback = new ListUpdateCallback() { private final ListUpdateCallback listUpdateCallback = new ListUpdateCallback() {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
notifyItemRangeInserted(position + 1, count); notifyItemRangeInserted(position + 1, count);
...@@ -117,7 +117,7 @@ public abstract class ExtRealmModelListAdapter<T extends RealmObject, VM, ...@@ -117,7 +117,7 @@ public abstract class ExtRealmModelListAdapter<T extends RealmObject, VM,
} }
@Override @Override
public ListUpdateCallback getListUpdateCallback() { protected ListUpdateCallback getListUpdateCallback() {
return listUpdateCallback; return listUpdateCallback;
} }
......
...@@ -103,7 +103,31 @@ public abstract class RealmModelListAdapter<T extends RealmObject, VM, ...@@ -103,7 +103,31 @@ public abstract class RealmModelListAdapter<T extends RealmObject, VM,
protected abstract DiffUtil.Callback getDiffCallback(List<VM> oldData, List<VM> newData); protected abstract DiffUtil.Callback getDiffCallback(List<VM> oldData, List<VM> newData);
protected abstract ListUpdateCallback getListUpdateCallback(); private final ListUpdateCallback listUpdateCallback = new ListUpdateCallback() {
@Override
public void onInserted(int position, int count) {
notifyItemRangeInserted(position, count);
}
@Override
public void onRemoved(int position, int count) {
notifyItemRangeRemoved(position, count);
}
@Override
public void onMoved(int fromPosition, int toPosition) {
notifyItemMoved(fromPosition, toPosition);
}
@Override
public void onChanged(int position, int count, Object payload) {
notifyItemRangeChanged(position, count, payload);
}
};
protected ListUpdateCallback getListUpdateCallback() {
return listUpdateCallback;
}
public void setOnItemClickListener(OnItemClickListener<VM> onItemClickListener) { public void setOnItemClickListener(OnItemClickListener<VM> onItemClickListener) {
this.onItemClickListener = onItemClickListener; this.onItemClickListener = onItemClickListener;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment