Closed cucko closed 11 years ago
hm, its not that. my issue is that when user want to scroll the list, if he does a little angled move (not straight vertical), there is a very good chance that the motion is detected as fling/remove and removes the item instead of scrolling the list.
@cucko , find the method in DragSortController.java, and try to make mTouchSlop BIGGER.
public DragSortController(DragSortListView dslv, int dragHandleId,
int dragInitMode, int removeMode, int clickRemoveId,
int flingHandleId) {
super(dslv);
mDslv = dslv;
mDetector = new GestureDetector(dslv.getContext(), this);
mFlingRemoveDetector = new GestureDetector(dslv.getContext(),
mFlingRemoveListener);
mFlingRemoveDetector.setIsLongpressEnabled(false);
mTouchSlop = ViewConfiguration.get(dslv.getContext())
.getScaledTouchSlop(); // ***to slow down the fling, you could set [mTouchSlop *= 4;]***
mDragHandleId = dragHandleId;
mClickRemoveId = clickRemoveId;
mFlingHandleId = flingHandleId;
setRemoveMode(removeMode);
setDragInitMode(dragInitMode);
}
@bullda thank you, that's exactly what i was looking for.
FYI, I've found a good way to make the sensitivity better (at least for my uses). Basically I found that when I scroll the list sometimes the item would get flinged off. To solve this I adjusted the onScroll method in DragSortController to only fling if the horizontal difference was greater than 2 times the vertical difference. That is, make sure that the user isn't dragging more vertically than horizontally before flinging. Code:
} else if (mFlingHitPos != MISS) { if (Math.abs(x2 - x1) > mTouchSlop && mRemoveEnabled /\ I added this to the conditional */ && Math.abs(x2 - x1) > 2 \ Math.abs(y2 - y1)) { mIsRemoving = true; startDrag(mFlingHitPos, deltaX, deltaY); } else if (Math.abs(y2 - y1) > mTouchSlop) { mCanDrag = false; // if started to scroll the list then // don't allow sorting nor fling-removing } }
Thank you very much. The solution is very useful.
That helped a lot!
Black tiger's solution is best, thanks a lot
Is there a way to set/change 'fling to remove' sensitivity (probably velocity check). i have listview where both drag to sort, and fling to remove are enabled. but almost 50% it removes the items instead of scroll the list. thanks for your great library.