Skip to content

Commit 1bbcf0c

Browse files
committed
flingOrSlide working with onDown and onLongPress drag init modes
1 parent b0901a1 commit 1bbcf0c

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

library/src/com/mobeta/android/dslv/DragSortController.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ public boolean onTouch(View v, MotionEvent ev) {
274274
}
275275
}
276276
case MotionEvent.ACTION_CANCEL:
277+
mIsRemoving = false;
277278
mDragging = false;
278279
break;
279280
}
@@ -407,10 +408,12 @@ public boolean onDown(MotionEvent ev) {
407408
}
408409

409410
mHitPos = startDragPosition(ev);
410-
if (mHitPos != MISS && mDragInitMode == ON_DOWN && mRemoveMode!=FLING_OR_SLIDE_REMOVE) {
411-
startDrag(mHitPos, (int) ev.getX() - mItemX, (int) ev.getY() - mItemY);
411+
mRemoveHitPos = MISS;
412+
boolean startedDrag = false;
413+
if (mHitPos != MISS && mDragInitMode == ON_DOWN ) {
414+
startedDrag = startDrag(mHitPos, (int) ev.getX() - mItemX, (int) ev.getY() - mItemY);
412415
}
413-
if( mRemoveMode == FLING_OR_SLIDE_REMOVE )
416+
if( !startedDrag && mRemoveMode == FLING_OR_SLIDE_REMOVE )
414417
{
415418
mCanDrag = true;
416419
mPositionX = 0;
@@ -476,7 +479,7 @@ else if (mHitPos != MISS && mDragInitMode == ON_DRAG && !mDragging) {
476479
@Override
477480
public void onLongPress(MotionEvent e) {
478481
//Log.d("mobeta", "lift listener long pressed");
479-
if (mHitPos != MISS && mDragInitMode == ON_LONG_PRESS && mRemoveMode!=FLING_OR_SLIDE_REMOVE) {
482+
if (mHitPos != MISS && mDragInitMode == ON_LONG_PRESS ) {
480483
mDslv.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
481484
startDrag(mHitPos, mCurrX - mItemX, mCurrY - mItemY);
482485
}
@@ -510,6 +513,7 @@ public void onShowPress(MotionEvent ev) {
510513
@Override
511514
public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
512515
//Log.d("mobeta", "on fling remove called");
516+
mIsRemoving = false;
513517
if (mRemoveEnabled) {
514518
switch (mRemoveMode) {
515519
case FLING_OR_SLIDE_REMOVE:
@@ -522,21 +526,13 @@ public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, fl
522526
{
523527
mDslv.stopDragWithVelocity(true,velocityX);
524528
}
525-
else
526-
{
527-
mIsRemoving = false;
528-
}
529529
}
530530
else if (velocityX < -mFlingSpeed )
531531
{
532532
if( mPositionX < minPos )
533533
{
534534
mDslv.stopDragWithVelocity(true,velocityX);
535535
}
536-
else
537-
{
538-
mIsRemoving = false;
539-
}
540536
}
541537
}
542538
break;

0 commit comments

Comments
 (0)