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

The following examples show how to use android.view.View#removeCallbacks() . 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 check out the related API usage on the sidebar.
Example 1
Source File: ViewPropertyAnimatorPreHC.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
@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
Source File: ViewPropertyAnimatorHC.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@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
Source File: UcNewsHeaderPagerBehavior.java    From UcMainPagerDemo with Apache License 2.0 6 votes vote down vote up
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
Source File: ViewPropertyAnimatorHC.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source File: GroupHeaderBehavior.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
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 6
Source File: NoteActivity.java    From DragLinearLayout with 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 7
Source File: Utils.java    From FoldableLayout with 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 8
Source File: ViewTransformDelegater.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 実行待機中のタスクがあればクリアする
 */
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 9
Source File: ViewPropertyAnimatorCompat.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
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
Source File: ColdAdvanceActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: ViewPropertyAnimatorPreHC.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 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 12
Source File: ViewPropertyAnimatorCompat.java    From letv with 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 13
Source File: UCViewHeaderBehavior.java    From UCMainViewForBehavior with Apache License 2.0 5 votes vote down vote up
/**
 * @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 14
Source File: UCViewHeaderBehavior.java    From UCMainViewForBehavior with Apache License 2.0 5 votes vote down vote up
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 15
Source File: TouchTracker.java    From AcDisplay with GNU General Public License v2.0 4 votes vote down vote up
void removeLongPressCallback(View target) {
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
Example 16
Source File: OnceRunnable.java    From FloatBall with Apache License 2.0 4 votes vote down vote up
public void removeSelf(View carrier) {
    mScheduled = false;
    carrier.removeCallbacks(this);
}
 
Example 17
Source File: DrawableHotspotTouch.java    From RippleDrawable with MIT License 4 votes vote down vote up
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
Example 18
Source File: TouchTracker.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
void removeLongPressCallback(View target){
    if (mPendingCheckForLongPress != null) {
        target.removeCallbacks(mPendingCheckForLongPress);
    }
}
 
Example 19
Source File: TouchTracker.java    From Mover with Apache License 2.0 4 votes vote down vote up
void removeTapCallback(View target){
    if(mPendingCheckForTap != null){
        target.removeCallbacks(mPendingCheckForTap);
    }
}
 
Example 20
Source File: FocusLayoutHelper.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
private void stopPressConfirm(View view) {
    if (view != null) {
        view.removeCallbacks(mConfirmPressRunnable);
    }
}