Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
@Nullable
OnDragStateChangedListener dragStateChangedListener;

private long pressDelayMillis = 0;


public interface OnItemMovedListener
Expand Down Expand Up @@ -138,6 +139,10 @@ public void setAutoScrollSpeed(float speed)
autoScrollSpeed = speed;
}

public void setPressDelayMillis(long pressDelayMillis) {
this.pressDelayMillis = pressDelayMillis;
}

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView rv, RecyclerView.State state) {
super.getItemOffsets(outRect, view, rv, state);
Expand All @@ -149,7 +154,7 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView rv, RecyclerVie
{
int itemPos = rv.getChildPosition(view);
debugLog("itemPos =" + itemPos);

if(!canDragOver(itemPos)) {
return;
}
Expand Down Expand Up @@ -321,8 +326,9 @@ else if (viewHandleId != -1)
debugLog("handlePos = " + handlePos[0] + " " + handlePos[1]);
}

long eventDuration = e.getEventTime() - e.getDownTime();

if (dragging)
if (dragging && eventDuration >= pressDelayMillis)
{
debugLog("Started Drag");

Expand Down Expand Up @@ -397,6 +403,11 @@ else if (fingerY < (rv.getHeight() * autoScrollWindow))
rv.invalidateItemDecorations();// Redraw
}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}

private void setIsDragging(final boolean dragging) {
if(dragging != isDragging) {
isDragging = dragging;
Expand Down Expand Up @@ -439,7 +450,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
fingerAnchorY -= dy;
}
};

/**
*
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
dragSortRecycler.setFloatingBgColor(0x800000FF);
dragSortRecycler.setAutoScrollSpeed(0.3f);
dragSortRecycler.setAutoScrollWindow(0.1f);
dragSortRecycler.setPressDelayMillis(350);

dragSortRecycler.setOnItemMovedListener(new DragSortRecycler.OnItemMovedListener() {
@Override
Expand Down