Java Code Examples for android.view.View#removeCallbacks()

The following examples show how to use android.view.View#removeCallbacks() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@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);
    }
}
 
Example 2
@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);
    }
}
 
Example 3
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);
    }

}
 
Example 4
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);
    }
}
 
Example 5
/**
 * @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);
    }
}
 
Example 6
Source Project: letv   File: ViewPropertyAnimatorCompat.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 7
/**
 * 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);
    }
}
 
Example 8
@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);
}
 
Example 9
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);
}
 
Example 10
/**
 * 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);
    }
}
 
Example 11
/**
 * 実行待機中のタスクがあればクリアする
 */
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);
}
 
Example 12
Source Project: FoldableLayout   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 13
Source Project: DragLinearLayout   File: NoteActivity.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 14
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);
        }

    }


}
 
Example 15
void removeLongPressCallback(View target) {
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
Example 16
Source Project: RippleDrawable   File: DrawableHotspotTouch.java    License: MIT License 4 votes vote down vote up
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
Example 17
Source Project: FloatBall   File: OnceRunnable.java    License: Apache License 2.0 4 votes vote down vote up
public void removeSelf(View carrier) {
    mScheduled = false;
    carrier.removeCallbacks(this);
}
 
Example 18
Source Project: UltimateAndroid   File: TouchTracker.java    License: Apache License 2.0 4 votes vote down vote up
void removeLongPressCallback(View target){
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
Example 19
Source Project: Mover   File: TouchTracker.java    License: Apache License 2.0 4 votes vote down vote up
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
Example 20
Source Project: ticdesign   File: FocusLayoutHelper.java    License: Apache License 2.0 4 votes vote down vote up
private void stopPressConfirm(View view) {
    if (view != null) {
        view.removeCallbacks(mConfirmPressRunnable);
    }
}