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

The following are Jave code examples for showing how to use removeCallbacks() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PeSanKita-android   File: RepeatableImageKey.java   Source Code and License Vote up 7 votes
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
  switch (motionEvent.getAction()) {
  case MotionEvent.ACTION_DOWN:
    view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
                               ? ViewConfiguration.getKeyRepeatTimeout()
                               : ViewConfiguration.getLongPressTimeout());
    performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    return false;
  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    view.removeCallbacks(repeater);
    return false;
  default:
    return false;
  }
}
 
Example 2
Project: Nird2   File: RepeatableImageKey.java   Source Code and License Vote up 6 votes
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
	switch (motionEvent.getAction()) {
		case ACTION_DOWN:
			view.postDelayed(repeater,
					ViewConfiguration.getKeyRepeatTimeout());
			performHapticFeedback(KEYBOARD_TAP);
			return false;
		case ACTION_CANCEL:
		case ACTION_UP:
			view.removeCallbacks(repeater);
			return false;
		default:
			return false;
	}
}
 
Example 3
Project: Nird2   File: RepeatableImageKey.java   Source Code and License Vote up 6 votes
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
	switch (motionEvent.getAction()) {
		case ACTION_DOWN:
			view.postDelayed(repeater,
					ViewConfiguration.getKeyRepeatTimeout());
			performHapticFeedback(KEYBOARD_TAP);
			return false;
		case ACTION_CANCEL:
		case ACTION_UP:
			view.removeCallbacks(repeater);
			return false;
		default:
			return false;
	}
}
 
Example 4
Project: boohee_v5.6   File: ViewPropertyAnimatorHC.java   Source Code and License Vote up 6 votes
private void animatePropertyBy(int constantName, float startValue, float byValue) {
    if (this.mAnimatorMap.size() > 0) {
        Animator animatorToCancel = null;
        for (Animator runningAnim : this.mAnimatorMap.keySet()) {
            PropertyBundle bundle = (PropertyBundle) this.mAnimatorMap.get(runningAnim);
            if (bundle.cancel(constantName) && bundle.mPropertyMask == 0) {
                animatorToCancel = runningAnim;
                break;
            }
        }
        if (animatorToCancel != null) {
            animatorToCancel.cancel();
        }
    }
    this.mPendingAnimations.add(new NameValuesHolder(constantName, startValue, byValue));
    View v = (View) this.mView.get();
    if (v != null) {
        v.removeCallbacks(this.mAnimationStarter);
        v.post(this.mAnimationStarter);
    }
}
 
Example 5
Project: android-project-gallery   File: ViewPropertyAnimatorPreHC.java   Source Code and License Vote up 6 votes
/**
 * 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 6
Project: CoordinatorLayoutExample-master   File: UcNewsHeaderPagerBehavior.java   Source Code and License Vote up 6 votes
private void handleActionUp(CoordinatorLayout parent, final View child) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "handleActionUp: ");
    }
    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 7
Project: android-project-gallery   File: ViewPropertyAnimatorHC.java   Source Code and License Vote up 6 votes
@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 8
Project: boohee_v5.6   File: ViewPropertyAnimatorCompat.java   Source Code and License Vote up 5 votes
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 9
Project: boohee_v5.6   File: ViewPropertyAnimatorPreHC.java   Source Code and License Vote up 5 votes
public void cancel() {
    if (this.mAnimatorMap.size() > 0) {
        for (Animator runningAnim : ((HashMap) this.mAnimatorMap.clone()).keySet()) {
            runningAnim.cancel();
        }
    }
    this.mPendingAnimations.clear();
    View v = (View) this.mView.get();
    if (v != null) {
        v.removeCallbacks(this.mAnimationStarter);
    }
}
 
Example 10
Project: UCMainViewForBehavior   File: UCViewHeaderBehavior.java   Source Code and License Vote up 5 votes
/**
 * @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 11
Project: UCMainViewForBehavior   File: UCViewHeaderBehavior.java   Source Code and License Vote up 5 votes
/**
 * @param duration close animation duration
 */
public void closePager(int duration) {
    View child = mChild.get();
    if (!isClosed()) {
        if (mFlingRunnable != null) {
            child.removeCallbacks(mFlingRunnable);
            mFlingRunnable = null;
        }
        mFlingRunnable = new FlingRunnable(child);
        mFlingRunnable.scrollToClosed(duration);
    }
}
 
Example 12
Project: letv   File: ViewPropertyAnimatorCompat.java   Source Code and License Vote up 5 votes
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
Project: exciting-app   File: ViewPropertyAnimatorHC.java   Source Code and License Vote up 5 votes
/**
 * 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 14
Project: UcMainPagerDemo-master   File: UcNewsHeaderPagerBehavior.java   Source Code and License Vote up 5 votes
/**
 * @param duration close animation duration
 */
public void closePager(int duration) {
    View child = mChild.get();
    CoordinatorLayout parent = mParent.get();
    if (!isClosed()) {
        if (mFlingRunnable != null) {
            child.removeCallbacks(mFlingRunnable);
            mFlingRunnable = null;
        }
        mFlingRunnable = new FlingRunnable(parent, child);
        mFlingRunnable.scrollToClosed(duration);
    }
}
 
Example 15
Project: exciting-app   File: ViewPropertyAnimatorPreHC.java   Source Code and License Vote up 5 votes
/**
 * 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 16
Project: CoordinatorLayoutExample-master   File: UcNewsHeaderPagerBehavior.java   Source Code and License Vote up 5 votes
/**
 * @param duration close animation duration
 */
public void closePager(int duration) {
    View child = mChild.get();
    CoordinatorLayout parent = mParent.get();
    if (!isClosed()) {
        if (mFlingRunnable != null) {
            child.removeCallbacks(mFlingRunnable);
            mFlingRunnable = null;
        }
        mFlingRunnable = new FlingRunnable(parent, child);
        mFlingRunnable.scrollToClosed(duration);
    }
}
 
Example 17
Project: BehaviorDemo   File: MainHeaderBehavior.java   Source Code and License Vote up 5 votes
private void handleActionUp(View child) {
    if (mFlingRunnable != null) {
        child.removeCallbacks(mFlingRunnable);
        mFlingRunnable = null;
    }
    //手指抬起时,header上滑距离超过总距离三分之一,则整体自动上滑到关闭状态
    if (child.getTranslationY() < getHeaderOffset() / 3.0f) {
        scrollToClose(DURATION_SHORT);
    } else {
        scrollToOpen(DURATION_SHORT);
    }
}
 
Example 18
Project: CustomAndroidOneSheeld   File: ColorDetectionFragment.java   Source Code and License Vote up 5 votes
@Override
    public void onColorChanged(final int... color) {
        if (normalColor != null && getView() != null && getApplication().getRunningShields().get(
                getControllerTag()) != null) {
            if (((ColorDetectionShield) getApplication().getRunningShields().get(
                    getControllerTag())).getRecevedFramesOperation() == ColorDetectionShield.RECEIVED_FRAMES.CENTER && color.length > 0) {
                uiHandler.removeCallbacks(null);
                uiHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        normalColor.setBackgroundColor(color[0]);
                    }
                });
            } else if (((ColorDetectionShield) getApplication().getRunningShields().get(
                    getControllerTag())).getRecevedFramesOperation() == ColorDetectionShield.RECEIVED_FRAMES.NINE_FRAMES && color.length > 0) {
                int k = 0;
                for (int i = 0; i < fullColor.getChildCount(); i++) {
                    for (int j = 0; j < ((LinearLayout) fullColor.getChildAt(i)).getChildCount(); j++) {
                        final View cell = ((LinearLayout) fullColor.getChildAt(i)).getChildAt(j);
                        final int m = k;
                        cell.removeCallbacks(null);
                        cell.post(new Runnable() {
                            @Override
                            public void run() {
                                if (m < color.length) {
//                                    Log.d("logColor", color.length + "   " + m + "   " + color[m]);
                                    cell.setBackgroundColor(color[m]);
                                }
                            }
                        });
                        k++;
                    }
                }
            }
        }
    }
 
Example 19
Project: boohee_v5.6   File: ViewPropertyAnimatorCompat.java   Source Code and License Vote up 5 votes
private void removeStartMessage(View view) {
    if (this.mStarterMap != null) {
        Runnable starter = (Runnable) this.mStarterMap.get(view);
        if (starter != null) {
            view.removeCallbacks(starter);
        }
    }
}
 
Example 20
Project: HandyGridView   File: OnceRunnable.java   Source Code and License Vote up 4 votes
public void removeSelf(View carrier) {
    mScheduled = false;
    carrier.removeCallbacks(this);
}