package com.mikepenz.fastadapter_extensions.drag;

import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;

import com.mikepenz.fastadapter.IDraggable;

/**
 * based on the sample from
 * https://github.com/AleBarreto/DragRecyclerView
 */
public class SimpleDragCallback extends ItemTouchHelper.SimpleCallback {

    //our callback
    private final ItemTouchCallback mCallbackItemTouch; // interface
    private boolean mIsDragEnabled = true;

    public SimpleDragCallback(ItemTouchCallback itemTouchCallback) {
        super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0);
        this.mCallbackItemTouch = itemTouchCallback;
    }

    public void setIsDragEnabled(boolean mIsDragEnabled) {
        this.mIsDragEnabled = mIsDragEnabled;
    }

    @Override
    public boolean isLongPressDragEnabled() {
        return mIsDragEnabled;
    }

    @Override
    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
        return mCallbackItemTouch.itemTouchOnMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); // information to the interface
    }

    @Override
    public int getDragDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
        if (viewHolder.itemView.getTag() instanceof IDraggable) {
            if (((IDraggable) viewHolder.itemView.getTag()).isDraggable()) {
                return super.getDragDirs(recyclerView, viewHolder);
            } else {
                return 0;
            }
        } else {
            return ItemTouchHelper.UP | ItemTouchHelper.DOWN;
        }
    }

    @Override
    public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
        // swiped disabled
    }
}
@@ -495,123 +495,670 @@
    p
-ublic SimpleDragCallback(ItemTouchCallback itemTouchCallback) %7B%0A        super(ItemTouchHelper.UP %7C ItemTouchHelper.
+rivate int mDirections = UP_DOWN;%0A%0A    public static final int ALL = ItemTouchHelper.UP %7C ItemTouchHelper.DOWN %7C ItemTouchHelper.LEFT %7C ItemTouchHelper.RIGHT;%0A    public static final int UP_DOWN = ItemTouchHelper.UP %7C ItemTouchHelper.DOWN;%0A%0A    @IntDef(%7BALL, UP_DOWN%7D)%0A    @Retention(RetentionPolicy.SOURCE)%0A    public @interface Directions %7B%0A    %7D%0A%0A    public SimpleDragCallback(@Directions int directions, ItemTouchCallback itemTouchCallback) %7B%0A        super(directions, 0);%0A        this.mDirections = directions;%0A        this.mCallbackItemTouch = itemTouchCallback;%0A    %7D%0A%0A    public SimpleDragCallback(ItemTouchCallback itemTouchCallback) %7B%0A        super(UP_
 DOWN
@@ -2140,49 +2140,19 @@
 urn 
-ItemTouchHelper.UP %7C ItemTouchHelper.DOWN
+mDirections
 ;%0A  

update SimpleDragCallback