Search in sources :

Example 6 with ItemAdapter

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());
}
Also used : FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter)

Aggregations

ItemAdapter (com.mikepenz.fastadapter.adapters.ItemAdapter)6 RecyclerView (android.support.v7.widget.RecyclerView)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 FastAdapter (com.mikepenz.fastadapter.FastAdapter)3 ArrayList (java.util.ArrayList)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 Toolbar (android.support.v7.widget.Toolbar)2 View (android.view.View)2 HeaderAdapter (com.mikepenz.fastadapter.adapters.HeaderAdapter)2 SimpleItem (com.mikepenz.fastadapter.app.items.SimpleItem)2 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)2 ActionMode (android.support.v7.view.ActionMode)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 Library (com.mikepenz.aboutlibraries.entity.Library)1 LibraryItem (com.mikepenz.aboutlibraries.ui.item.LibraryItem)1 LoaderItem (com.mikepenz.aboutlibraries.ui.item.LoaderItem)1 IItem (com.mikepenz.fastadapter.IItem)1 StickyHeaderAdapter (com.mikepenz.fastadapter.app.adapters.StickyHeaderAdapter)1 FastItemAdapter (com.mikepenz.fastadapter.commons.adapters.FastItemAdapter)1