public static int getPointerIndex(int action) { if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { return getPointerIndexHoneyComb(action); } else { return getPointerIndexEclair(action); } }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { postOnAnimationJellyBean(view, runnable); } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); } }
@Override public void run() { float t = interpolate(); float scale = mZoomStart + t * (mZoomEnd - mZoomStart); float deltaScale = scale / getScale(); onScale(deltaScale, mFocalX, mFocalY); if (t < 1f) { Compat.postOnAnimation(CropView.this, this); } }
@Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getPointerId(0); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: mActivePointerId = INVALID_POINTER_ID; break; case MotionEvent.ACTION_POINTER_UP: // Ignore deprecation, ACTION_POINTER_ID_MASK and // ACTION_POINTER_ID_SHIFT has same value and are deprecated // You can have either deprecation or lint target api warning final int pointerIndex = Compat.getPointerIndex(ev.getAction()); final int pointerId = ev.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { // This was our active pointer going up. Choose a new // active pointer and adjust accordingly. final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = ev.getPointerId(newPointerIndex); mLastTouchX = ev.getX(newPointerIndex); mLastTouchY = ev.getY(newPointerIndex); } break; } mActivePointerIndex = ev.findPointerIndex(mActivePointerId != INVALID_POINTER_ID ? mActivePointerId : 0); return super.onTouchEvent(ev); }
@Override public void run() { float t = interpolate(); float scale = mZoomStart + t * (mZoomEnd - mZoomStart); float deltaScale = scale / getScale(); onScale(deltaScale, mFocalX, mFocalY); if (t < 1f) { Compat.postOnAnimation(CropView.this, this); } }
@Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mActivePointerId = ev.getPointerId(0); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: mActivePointerId = INVALID_POINTER_ID; break; case MotionEvent.ACTION_POINTER_UP: // Ignore deprecation, ACTION_POINTER_ID_MASK and // ACTION_POINTER_ID_SHIFT has same value and are deprecated // You can have either deprecation or lint target api warning final int pointerIndex = Compat.getPointerIndex(ev.getAction()); final int pointerId = ev.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { // This was our active pointer going up. Choose a new // active pointer and adjust accordingly. final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = ev.getPointerId(newPointerIndex); mLastTouchX = ev.getX(newPointerIndex); mLastTouchY = ev.getY(newPointerIndex); } break; } mActivePointerIndex = ev.findPointerIndex(mActivePointerId != INVALID_POINTER_ID ? mActivePointerId : 0); return super.onTouchEvent(ev); }
public static int getPointerIndex(int action) { if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { return getPointerIndexHoneyComb(action); } else { return getPointerIndexEclair(action); } }
@Override public void run() { if (mScroller.isFinished()) { return; } if (mScroller.computeScrollOffset()) { final int newX = mScroller.getCurrX(); final int newY = mScroller.getCurrY(); mSuppMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY); setImageMatrix(getDrawMatrix()); mCurrentX = newX; mCurrentY = newY; Compat.postOnAnimation(CropView.this, this); } } }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { postOnAnimationJellyBean(view, runnable); } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); } }
@Override public void run() { if (mScroller.isFinished()) { return; } if (mScroller.computeScrollOffset()) { final int newX = mScroller.getCurrX(); final int newY = mScroller.getCurrY(); mSuppMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY); setImageMatrix(getDrawMatrix()); mCurrentX = newX; mCurrentY = newY; Compat.postOnAnimation(CropView.this, this); } } }