List of usage examples for android.view View removeCallbacks
public boolean removeCallbacks(Runnable action)
Removes the specified Runnable from the message queue.
From source file:com.ycl.framework.photoview.PhotoViewAttacher.java
@Override public boolean onTouch(final View v, MotionEvent ev) { boolean handled = false; if (mZoomEnabled && hasDrawable((ImageView) v)) { ViewParent parent = v.getParent(); switch (ev.getAction()) { case ACTION_DOWN: // First, disable the Parent from intercepting the touch // event v.removeCallbacks(mRunColse); if (null != parent) parent.requestDisallowInterceptTouchEvent(true); else/* w ww . j av a 2s .co m*/ Log.i(LOG_TAG, "onTouch getParent() returned null"); //? lastPosX = ev.getX(); lastPosY = ev.getY(); // If we're flinging, and the user presses down, cancel // fling cancelFling(); break; case ACTION_CANCEL: case ACTION_UP: // If the user has zoomed less than min scale, zoom back // to min scale if (getScale() < mMinScale) { RectF rect = getDisplayRect(); if (null != rect) { v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY())); handled = true; } } //?click if (Math.abs(ev.getX() - lastPosX) < 4 && Math.abs(ev.getY() - lastPosY) < 4) { if (OnDoubleTap) { OnDoubleTap = false; } else v.postDelayed(mRunColse, 330); } else { OnDoubleTap = false; } break; } // Try the Scale/Drag detector if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) { handled = true; } // Check to see if the user double tapped if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) { handled = true; } } return handled; }
From source file:com.taobao.weex.dom.transition.WXTransition.java
/** * doTransitionAnimation include transform and layout animation. * 1. put pre transition updates from target style to dom style * 2. do transform animation and layout animation * *//*from www .ja v a 2s. c o m*/ private void doTransitionAnimation(final int token) { final View taregtView = getTargetView(); if (taregtView == null) { return; } if (targetStyles.size() > 0) { for (String property : properties) { if (!(LAYOUT_PROPERTIES.contains(property) || TRANSFORM_PROPERTIES.contains(property))) { continue; } if (layoutPendingUpdates.containsKey(property)) { continue; } if (transformPendingUpdates.containsKey(property)) { continue; } synchronized (targetStyles) { if (targetStyles.containsKey(property)) { //reset pre transition style Object targetValue = targetStyles.remove(property); domObject.getStyles().put(property, targetValue); WXComponent component = getComponent(); if (component != null && component.getDomObject() != null) { component.getDomObject().getStyles().put(property, targetValue); } } } } } if (transitionEndEvent != null) { taregtView.removeCallbacks(transitionEndEvent); } if (transitionEndEvent == null && duration > Float.MIN_NORMAL) { transitionEndEvent = new Runnable() { @Override public void run() { transitionEndEvent = null; if (duration < Float.MIN_NORMAL) { return; } WXComponent component = getComponent(); if (component != null && domObject.getEvents().contains(Constants.Event.ON_TRANSITION_END)) { component.fireEvent(Constants.Event.ON_TRANSITION_END); } } }; } if (transformAnimationRunnable != null) { taregtView.removeCallbacks(transformAnimationRunnable); } transformAnimationRunnable = new Runnable() { @Override public void run() { synchronized (lockToken) { if (token == lockToken.get()) { doPendingTransformAnimation(token); } } } }; taregtView.post(transformAnimationRunnable); doPendingLayoutAnimation(); }