android.view.View#removeCallbacks ( )源码实例Demo

下面列出了android.view.View#removeCallbacks ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void cancel() {
    if (mAnimatorMap.size() > 0) {
        HashMap<Animator, PropertyBundle> mAnimatorMapCopy =
                (HashMap<Animator, PropertyBundle>)mAnimatorMap.clone();
        Set<Animator> animatorSet = mAnimatorMapCopy.keySet();
        for (Animator runningAnim : animatorSet) {
            runningAnim.cancel();
        }
    }
    mPendingAnimations.clear();
    View v = mView.get();
    if (v != null) {
        v.removeCallbacks(mAnimationStarter);
    }
}
 
源代码2 项目: UltimateAndroid   文件: ViewPropertyAnimatorHC.java
@Override
public void cancel() {
    if (mAnimatorMap.size() > 0) {
        HashMap<Animator, PropertyBundle> mAnimatorMapCopy =
                (HashMap<Animator, PropertyBundle>)mAnimatorMap.clone();
        Set<Animator> animatorSet = mAnimatorMapCopy.keySet();
        for (Animator runningAnim : animatorSet) {
            runningAnim.cancel();
        }
    }
    mPendingAnimations.clear();
    View v = mView.get();
    if (v != null) {
        v.removeCallbacks(mAnimationStarter);
    }
}
 
private void settle(CoordinatorLayout parent, final View child) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "settle: ");
    }
    if (mFlingRunnable != null) {
        child.removeCallbacks(mFlingRunnable);
        mFlingRunnable = null;
    }
    mFlingRunnable = new FlingRunnable(parent, child);
    if (child.getTranslationY() < getHeaderOffsetRange() / 3.0f) {
        mFlingRunnable.scrollToClosed(DURATION_SHORT);
    } else {
        mFlingRunnable.scrollToOpen(DURATION_SHORT);
    }

}
 
private void handlerActionUp(View child) {
    if (mFlingRunnable != null) {
        child.removeCallbacks(mFlingRunnable);
        mFlingRunnable = null;
    }
    mFlingRunnable = new FlingRunnable(child);
    if (child.getTranslationY() < getHeaderOffsetRange() / 4.0f) {
        mFlingRunnable.scrollToClosed(DURATION_SHORT);
    } else {
        mFlingRunnable.scrollToOpen(DURATION_SHORT);
    }
}
 
/**
 * @param duration open animation duration
 */
public void openPager(int duration) {
    View child = mChild.get();
    if (isClosed() && child != null) {
        if(child.getVisibility() == View.GONE) {
            child.setVisibility(View.VISIBLE);
        }
        if (mFlingRunnable != null) {
            child.removeCallbacks(mFlingRunnable);
            mFlingRunnable = null;
        }
        mFlingRunnable = new FlingRunnable(child);
        mFlingRunnable.scrollToOpen(duration);
    }
}
 
源代码6 项目: letv   文件: ViewPropertyAnimatorCompat.java
private void postStartMessage(ViewPropertyAnimatorCompat vpa, View view) {
    Runnable runnable = null;
    if (this.mStarterMap != null) {
        runnable = (Runnable) this.mStarterMap.get(view);
    }
    if (runnable == null) {
        runnable = new Starter(vpa, view);
        if (this.mStarterMap == null) {
            this.mStarterMap = new WeakHashMap();
        }
        this.mStarterMap.put(view, runnable);
    }
    view.removeCallbacks(runnable);
    view.post(runnable);
}
 
/**
 * Utility function, called by animateProperty() and animatePropertyBy(), which handles the
 * details of adding a pending animation and posting the request to start the animation.
 *
 * @param constantName The specifier for the property being animated
 * @param startValue The starting value of the property
 * @param byValue The amount by which the property will change
 */
private void animatePropertyBy(int constantName, float startValue, float byValue) {
    // First, cancel any existing animations on this property
    if (mAnimatorMap.size() > 0) {
        Animator animatorToCancel = null;
        Set<Animator> animatorSet = mAnimatorMap.keySet();
        for (Animator runningAnim : animatorSet) {
            PropertyBundle bundle = mAnimatorMap.get(runningAnim);
            if (bundle.cancel(constantName)) {
                // property was canceled - cancel the animation if it's now empty
                // Note that it's safe to break out here because every new animation
                // on a property will cancel a previous animation on that property, so
                // there can only ever be one such animation running.
                if (bundle.mPropertyMask == NONE) {
                    // the animation is no longer changing anything - cancel it
                    animatorToCancel = runningAnim;
                    break;
                }
            }
        }
        if (animatorToCancel != null) {
            animatorToCancel.cancel();
        }
    }

    NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
    mPendingAnimations.add(nameValuePair);
    View v = mView.get();
    if (v != null) {
        v.removeCallbacks(mAnimationStarter);
        v.post(mAnimationStarter);
    }
}
 
源代码8 项目: bither-android   文件: ColdAdvanceActivity.java
@Override
public void onClick(View v) {
    v.removeCallbacks(delay);
    clickedTime++;
    if (clickedTime >= 7) {
        new DialogEnterpriseHDMEnable(ColdAdvanceActivity.this).show();
        clickedTime = 0;
        return;
    }
    v.postDelayed(delay, 400);
}
 
private void postStartMessage(ViewPropertyAnimatorCompat vpa, View view) {
    Runnable starter = null;
    if (mStarterMap != null) {
        starter = mStarterMap.get(view);
    }
    if (starter == null) {
        starter = new Starter(vpa, view);
        if (mStarterMap == null) {
            mStarterMap = new WeakHashMap<View, Runnable>();
        }
        mStarterMap.put(view, starter);
    }
    view.removeCallbacks(starter);
    view.post(starter);
}
 
/**
 * Utility function, called by animateProperty() and animatePropertyBy(), which handles the
 * details of adding a pending animation and posting the request to start the animation.
 *
 * @param constantName The specifier for the property being animated
 * @param startValue The starting value of the property
 * @param byValue The amount by which the property will change
 */
private void animatePropertyBy(int constantName, float startValue, float byValue) {
    // First, cancel any existing animations on this property
    if (mAnimatorMap.size() > 0) {
        Animator animatorToCancel = null;
        Set<Animator> animatorSet = mAnimatorMap.keySet();
        for (Animator runningAnim : animatorSet) {
            PropertyBundle bundle = mAnimatorMap.get(runningAnim);
            if (bundle.cancel(constantName)) {
                // property was canceled - cancel the animation if it's now empty
                // Note that it's safe to break out here because every new animation
                // on a property will cancel a previous animation on that property, so
                // there can only ever be one such animation running.
                if (bundle.mPropertyMask == NONE) {
                    // the animation is no longer changing anything - cancel it
                    animatorToCancel = runningAnim;
                    break;
                }
            }
        }
        if (animatorToCancel != null) {
            animatorToCancel.cancel();
        }
    }

    NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
    mPendingAnimations.add(nameValuePair);
    View v = mView.get();
    if (v != null) {
        v.removeCallbacks(mAnimationStarter);
        v.post(mAnimationStarter);
    }
}
 
源代码11 项目: libcommon   文件: ViewTransformDelegater.java
/**
 * 実行待機中のタスクがあればクリアする
 */
public void clearPendingTasks() {
	if (DEBUG) Log.v(TAG, "clearPendingTasks:");
	final View view = getTargetView();
	if (mWaitImageReset != null)
		view.removeCallbacks(mWaitImageReset);
	if (mStartCheckRotate != null)
		view.removeCallbacks(mStartCheckRotate);
	if (mWaitReverseReset != null)
		view.removeCallbacks(mWaitReverseReset);
}
 
源代码12 项目: FoldableLayout   文件: Utils.java
static void postOnAnimation(View view, Runnable action) {
    view.removeCallbacks(action);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.postOnAnimationDelayed(action, FRAME_TIME);
    } else {
        view.postDelayed(action, FRAME_TIME);
    }
}
 
源代码13 项目: DragLinearLayout   文件: NoteActivity.java
/**
 * Opens or closes the IME.
 * If called in quick succession (i.e. before the message queue of the view is processed),
 * only the latest call will get executed.
 */
private void setImeVisibility(final View view, final boolean visible) {
    if (visible) {
        view.removeCallbacks(toggleImeRunnable);
        toggleImeRunnable = new Runnable() {
            public void run() {
                InputMethodManager imm = (InputMethodManager)
                        NoteActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);

                if (null != imm) {
                    imm.showSoftInput(view, 0);
                }
            }
        };
        view.post(toggleImeRunnable);
    } else {
        view.removeCallbacks(toggleImeRunnable);
        toggleImeRunnable = new Runnable() {
            public void run() {
                InputMethodManager imm = (InputMethodManager)
                        NoteActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);

                if (null != imm) {
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
            }
        };
        view.post(toggleImeRunnable);
    }
}
 
private void handleActionUp(CoordinatorLayout parent, final View child) {
    if (mFlingRunnable != null) {
        child.removeCallbacks(mFlingRunnable);
        mFlingRunnable = null;
    }

    mFlingRunnable = new FlingRunnable(parent, child);

    //notice  is a negative number
    float targetHeight = getHeaderOffsetRange() / 8.0f;
    float childTranslationY = child.getTranslationY();

    logD(TAG, "handleActionUp: childTranslationY=" + childTranslationY + "targetHeight=" +
            targetHeight + " mCurState= " + mCurState);

    if (mCurState == STATE_OPENED) {

        if (childTranslationY < targetHeight) {
            mFlingRunnable.scrollToClosed(DURATION_SHORT);
        } else {
            mFlingRunnable.scrollToOpen(DURATION_SHORT);
        }

    } else if (mCurState == STATE_CLOSED) {

        float percent = 1 - Math.abs(childTranslationY * 1.0f / getHeaderOffsetRange());
        childTranslationY = getHeaderOffsetRange() - childTranslationY;
        logD(TAG, "handleActionUp: childTranslationY=" + childTranslationY + "percent=" +
                percent);

        if (percent < 0.15) {
            mFlingRunnable.scrollToClosed(DURATION_SHORT);
        } else {
            mFlingRunnable.scrollToOpen(DURATION_SHORT);
        }

    }


}
 
源代码15 项目: AcDisplay   文件: TouchTracker.java
void removeLongPressCallback(View target) {
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
源代码16 项目: RippleDrawable   文件: DrawableHotspotTouch.java
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
源代码17 项目: FloatBall   文件: OnceRunnable.java
public void removeSelf(View carrier) {
    mScheduled = false;
    carrier.removeCallbacks(this);
}
 
源代码18 项目: UltimateAndroid   文件: TouchTracker.java
void removeLongPressCallback(View target){
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
源代码19 项目: Mover   文件: TouchTracker.java
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
源代码20 项目: ticdesign   文件: FocusLayoutHelper.java
private void stopPressConfirm(View view) {
    if (view != null) {
        view.removeCallbacks(mConfirmPressRunnable);
    }
}
 
 方法所在类
 同类方法