use of com.mikepenz.fastadapter.adapters.ItemAdapter in project FastAdapter by mikepenz.
the class SimpleDragCallback method onMove.
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
if (mCallbackItemTouch == null) {
RecyclerView.Adapter adapter = recyclerView.getAdapter();
ItemAdapter itemAdapter = null;
if (adapter instanceof FastItemAdapter) {
itemAdapter = ((FastItemAdapter) adapter).getItemAdapter();
} else if (adapter instanceof ItemAdapter) {
itemAdapter = (ItemAdapter) adapter;
}
if (itemAdapter != null) {
itemAdapter.move(itemAdapter.getFastAdapter().getHolderAdapterPosition(viewHolder), itemAdapter.getFastAdapter().getHolderAdapterPosition(target));
return true;
}
throw new RuntimeException("SimpleDragCallback without an callback is only allowed when using the ItemAdapter or the FastItemAdapter");
}
// information to the interface
return mCallbackItemTouch.itemTouchOnMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
}
Aggregations