下面列出了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);
}
}
@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);
}
}
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);
}
}
@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);
}
}
/**
* 実行待機中のタスクがあればクリアする
*/
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);
}
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);
}
}
/**
* 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);
}
}
}
void removeLongPressCallback(View target) {
if (mPendingCheckForLongPress != null) {
target.removeCallbacks(mPendingCheckForLongPress);
}
}
void removeTapCallback(View target){
if(mPendingCheckForTap != null){
target.removeCallbacks(mPendingCheckForTap);
}
}
public void removeSelf(View carrier) {
mScheduled = false;
carrier.removeCallbacks(this);
}
void removeLongPressCallback(View target){
if (mPendingCheckForLongPress != null) {
target.removeCallbacks(mPendingCheckForLongPress);
}
}
void removeTapCallback(View target){
if(mPendingCheckForTap != null){
target.removeCallbacks(mPendingCheckForTap);
}
}
private void stopPressConfirm(View view) {
if (view != null) {
view.removeCallbacks(mConfirmPressRunnable);
}
}