List of usage examples for android.view MotionEvent ACTION_POINTER_INDEX_MASK
int ACTION_POINTER_INDEX_MASK
To view the source code for android.view MotionEvent ACTION_POINTER_INDEX_MASK.
Click Source Link
From source file:com.kaplandroid.colorbook.SlidingLayer.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }//from w w w. j a va2 s. com final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float yDiff = Math.abs(y - mLastY); if (xDiff > mTouchSlop && xDiff > yDiff && allowDraging(dx)) { mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); } else if (yDiff > mTouchSlop) { mIsUnableToDrag = true; } break; case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEvent.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHere(ev)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:net.woggle.shackbrowse.SlideFrame.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }/*from w ww. j a v a 2s. co m*/ final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float yDiff = Math.abs(y - mLastY); if (xDiff > mTouchSlop && xDiff > yDiff && allowDragging(dx)) { mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); mOnInteractListener.onDrag(); } else if (yDiff > mTouchSlop) { mIsUnableToDrag = true; } break; case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEvent.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHere(ev)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:org.i_chera.wolfensteineditor.fragments.LevelFragment.java
@Override public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); if (mScrollLockCheck.isChecked()) { // We also need to avoid interfering with the left drawer // Cancel DOWN if too left. But don't cancel MOVE if too left if (v == mCentralContent && !mDrawerLayout.isDrawerVisible(Gravity.LEFT)) { int count = MotionEventCompat.getPointerCount(event); for (int k = 0; k < count; ++k) { if (action != MotionEvent.ACTION_DOWN && action != MotionEventCompat.ACTION_POINTER_DOWN || MotionEventCompat.getX(event, k) >= mTileSize) { hitTileOnView(event, k, false); }/*from w w w . j av a 2 s . co m*/ } return true; } return false; } if (v == mVerticalScroll) { // LOL trickery needed to scroll the below horiz view while this is // getting operated on if (mVerticalScroll.isScrollable() && mDoNotPropagateScroll == false) { mHorizontalScroll.setScrollingEnabled(true); mHorizontalScroll.dispatchTouchEvent(event); mHorizontalScroll.setScrollingEnabled(false); } if (action == MotionEvent.ACTION_DOWN || action == MotionEventCompat.ACTION_POINTER_DOWN) { mPressDown = true; //return true; } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) { if (mPressDown) { hitTileOnView(event, (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT, true); } } return false; } return false; }
From source file:net.osmand.plus.views.controls.DynamicListView.java
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { if (singleTapDetector.onTouchEvent(event)) { if (tag != null) { tag.onClick();/*from ww w . j a va2 s . co m*/ } touchEventsCancelled(); return super.onTouchEvent(event); } switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: if (!mCellIsMobile && mHoverCell == null) { // Find the view that the user pressed their finger down on. View v = findViewAtPositionWithDragIconTag(getRootView(), (int) event.getRawX(), (int) event.getRawY()); // If the view contains a tag set to "DragIcon" class, it means that the user wants to // reorder the list item. if ((v != null) && (v.getTag() != null) && (v.getTag() instanceof DragIcon)) { mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); mTotalOffset = 0; tag = (DragIcon) v.getTag(); int position = pointToPosition(mDownX, mDownY); if (position != INVALID_POSITION) { Object item = getAdapter().getItem(position); if (mActiveItemsList == null || mActiveItemsList.contains(item)) { int itemNum = position - getFirstVisiblePosition(); itemsSwapped = false; View selectedView = getChildAt(itemNum); mMobileItemId = getAdapter().getItemId(position); mHoverCell = getAndAddHoverView(selectedView); selectedView.setVisibility(INVISIBLE); mCellIsMobile = true; updateNeighborViewsForID(mMobileItemId); if (dCallbacks != null) { dCallbacks.onItemSwapping(position); } } } } } break; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER_ID) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile && mHoverCell != null) { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mHoverCellOriginalBounds.top + deltaY + mTotalOffset); mHoverCell.setBounds(mHoverCellCurrentBounds); invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } break; default: break; } return super.onTouchEvent(event); }
From source file:co.vn.e_alarm.customwiget.SlidingLayer.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }/*from www . j a va 2s . co m*/ final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { /* * Return event touch to children view. */ mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float dy = y - mLastY; final float yDiff = Math.abs(y - mLastY); if (xDiff > mTouchSlop && xDiff > yDiff && allowDragingX(dx, mInitialX)) { // mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); } else if (yDiff > mTouchSlop && yDiff > xDiff && allowDragingY(dy, mInitialY)) { // mIsDragging = true; mLastY = y; setDrawingCacheEnabled(true); } float matY = (float) Math.abs(corY - ev.getRawY()); float matX = (float) Math.abs(corX - ev.getRawX()); if (matY - 100 > 0) { mIsDragging = true; setDrawingCacheEnabled(true); // Dang di chuyen len } else if (matX - 100 > 0) { mIsDragging = false; } if (matY == 0) { setDrawingCacheEnabled(false); } /* }else{ mIsDragging = false; setDrawingCacheEnabled(true); }*/ /* }else if(corX +150 > ev.getRawX()){ mIsDragging = false; setDrawingCacheEnabled(true); }else if(corX +150 < ev.getRawX()){ mIsDragging = false; setDrawingCacheEnabled(true); }*/ // double corY = ev.getY(); break; case MotionEvent.ACTION_DOWN: corX = ev.getRawX(); corY = ev.getRawY(); mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEventCompat.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = mInitialY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHereX(ev, mInitialX)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else if (allowSlidingFromHereY(ev, mInitialY)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:com.danilov.supermanga.core.view.SlidingLayer.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }//from w w w . j a v a2 s .com final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float dy = y - mLastY; final float yDiff = Math.abs(y - mLastY); if (xDiff > mTouchSlop && xDiff > yDiff && allowDragingX(dx, mInitialX)) { mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); } else if (yDiff > mTouchSlop && yDiff > xDiff && allowDragingY(dy, mInitialY)) { mIsDragging = true; mLastY = y; setDrawingCacheEnabled(true); } break; case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEventCompat.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = mInitialY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHereX(ev, mInitialX)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else if (allowSlidingFromHereY(ev, mInitialY)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:bk.vinhdo.taxiads.utils.view.SlidingLayer.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }/*from w ww .j ava2 s .c om*/ final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float dy = y - mLastY; final float yDiff = Math.abs(y - mLastY); if (mOnInteractListener != null) { boolean isControlled = mOnInteractListener.onInterceptActionMove(x, y); if (isControlled) { break; } } if (xDiff > mTouchSlop && xDiff > yDiff && allowDragingX(dx, mInitialX)) { mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); } else if (yDiff > mTouchSlop && yDiff > xDiff && allowDragingY(dy, mInitialY)) { mIsDragging = true; mLastY = y; setDrawingCacheEnabled(true); } break; case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEventCompat.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = mInitialY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHereX(ev, mInitialX)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else if (allowSlidingFromHereY(ev, mInitialY)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:com.leeon.blank.widget.RangeBarNew.java
private void handleTouchDown(MotionEvent event) { final int actionIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int downX = (int) event.getX(actionIndex); final int downY = (int) event.getY(actionIndex); if (mLeftCursorRect.contains(downX, downY)) { if (mLeftHit) { return; }//from ww w . j av a2 s. co m // If hit, change state of drawable, and record id of touch pointer. mLeftPointerLastX = downX; mLeftCursorBG.setState(mPressedEnableState); mLeftPointerID = event.getPointerId(actionIndex); mLeftHit = true; invalidate(); } else if (mRightCursorRect.contains(downX, downY)) { if (mRightHit) { return; } mRightPointerLastX = downX; mRightCursorBG.setState(mPressedEnableState); mRightPointerID = event.getPointerId(actionIndex); mRightHit = true; invalidate(); } }
From source file:com.example.lansosdk.util.SlidingLayer.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) { return false; }/*w ww .ja va 2 s . co m*/ final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mIsDragging = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } return false; } if (action != MotionEvent.ACTION_DOWN) { if (mIsDragging) { return true; } else if (mIsUnableToDrag) { return false; } } switch (action) { case MotionEvent.ACTION_MOVE: final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER) { break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); if (pointerIndex == -1) { mActivePointerId = INVALID_POINTER; break; } final float x = MotionEventCompat.getX(ev, pointerIndex); final float dx = x - mLastX; final float xDiff = Math.abs(dx); final float y = MotionEventCompat.getY(ev, pointerIndex); final float dy = y - mLastY; final float yDiff = Math.abs(y - mLastY); if (xDiff > mTouchSlop && xDiff > yDiff && allowDragingX(dx, mInitialX)) { // mIsDragging = true; mLastX = x; setDrawingCacheEnabled(true); } else if (yDiff > mTouchSlop && yDiff > xDiff && allowDragingY(dy, mInitialY)) { // mIsDragging = true; mLastY = y; setDrawingCacheEnabled(true); } break; case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getAction() & (Build.VERSION.SDK_INT >= 8 ? MotionEvent.ACTION_POINTER_INDEX_MASK : MotionEventCompat.ACTION_POINTER_INDEX_MASK); mLastX = mInitialX = MotionEventCompat.getX(ev, mActivePointerId); mLastY = mInitialY = MotionEventCompat.getY(ev, mActivePointerId); if (allowSlidingFromHereX(ev, mInitialX)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else if (allowSlidingFromHereY(ev, mInitialY)) { mIsDragging = false; mIsUnableToDrag = false; // If nobody else got the focus we use it to close the layer return super.onInterceptTouchEvent(ev); } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsDragging) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsDragging; }
From source file:com.leeon.blank.widget.RangeBarNew.java
private void handleTouchUp(MotionEvent event) { final int actionIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int actionID = event.getPointerId(actionIndex); if (actionID == mLeftPointerID) { if (!mLeftHit) { return; }// ww w.ja v a 2s .c om // If cursor between in tow mark locations, it should be located on the lower or higher one. if (getDiffByX(event.getX()) == 1) { // step 1:Calculate the offset with lower mark. final float offset = mLeftCursorIndex % 5; // step 2:Decide which mark will go to. if (offset < 2.5f) { // If left cursor want to be located on lower mark, go ahead // guys. // Because right cursor will never appear lower than the // left one. mLeftCursorNextIndex = (int) (mLeftCursorIndex / 5) * 5; } else { mLeftCursorNextIndex = (int) (mLeftCursorIndex / 5) * 5 + 1; // If left cursor want to be located on higher mark, // situation becomes a little complicated. // We should check that whether distance between left and // right cursor is less than 1, and next index of left // cursor is difference with current // of right one. if (Math.abs(mLeftCursorIndex - mRightCursorIndex) <= 5 && mLeftCursorNextIndex == mRightCursorNextIndex) { // Left can not go to the higher, just to the lower one. mLeftCursorNextIndex = (int) (mLeftCursorIndex / 5) * 5; } } // step 3: Move to. if (!mLeftScroller.computeScrollOffset()) { final int fromX = (int) (mLeftCursorIndex * mTinyPartLength); mLeftScroller.startScroll(fromX, 0, (int) (mLeftCursorNextIndex * mTinyPartLength - fromX), 0, mDuration); } if (mLeftCursorNextIndex != mLeftCursorPreIndex) { mLeftCursorPreIndex = mLeftCursorNextIndex; } } // Reset values of parameters mLeftPointerLastX = 0; mLeftCursorBG.setState(mUnPressedEanabledState); mLeftPointerID = -1; mLeftHit = false; invalidate(); } else if (actionID == mRightPointerID) { if (!mRightHit) { return; } if (getDiffByX(event.getX()) == 1) { final float offset = mRightCursorIndex % 5; if (offset > 2.5f) { mRightCursorNextIndex = (int) (mRightCursorIndex / 5) * 5 + 1; } else { mRightCursorNextIndex = (int) (mRightCursorIndex / 5) * 5; if (Math.abs(mLeftCursorIndex - mRightCursorIndex) <= 5 && mRightCursorNextIndex == mLeftCursorNextIndex) { mRightCursorNextIndex = (int) (mRightCursorIndex / 5) * 5 + 1; } } if (!mRightScroller.computeScrollOffset()) { final int fromX = (int) (mRightCursorIndex * mTinyPartLength); mRightScroller.startScroll(fromX, 0, (int) (mRightCursorNextIndex * mTinyPartLength - fromX), 0, mDuration); } if (mRightCursorNextIndex != mRightCursorPreIndex) { mRightCursorPreIndex = mRightCursorNextIndex; } } mRightPointerLastX = 0; mLeftCursorBG.setState(mUnPressedEanabledState); mRightPointerID = -1; mRightHit = false; invalidate(); } }