Java Code Examples for android.animation.ValueAnimator#cancel()

The following examples show how to use android.animation.ValueAnimator#cancel() . 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: TapTargetView.java    From TapTargetView with Apache License 2.0 6 votes vote down vote up
void onDismiss(boolean userInitiated) {
  if (isDismissed) return;

  isDismissing = false;
  isDismissed = true;

  for (final ValueAnimator animator : animators) {
    animator.cancel();
    animator.removeAllUpdateListeners();
  }

  ViewUtil.removeOnGlobalLayoutListener(getViewTreeObserver(), globalLayoutListener);
  visible = false;

  if (listener != null) {
    listener.onTargetDismissed(this, userInitiated);
  }
}
 
Example 2
Source File: TapTargetView.java    From styT with Apache License 2.0 6 votes vote down vote up
void onDismiss(boolean userInitiated) {
    if (isDismissed) return;

    isDismissed = true;

    for (final ValueAnimator animator : animators) {
        animator.cancel();
        animator.removeAllUpdateListeners();
    }

    ViewUtil.removeOnGlobalLayoutListener(getViewTreeObserver(), globalLayoutListener);
    visible = false;

    if (listener != null) {
        listener.onTargetDismissed(this, userInitiated);
    }
}
 
Example 3
Source File: ViewHelper.java    From DMusic with Apache License 2.0 5 votes vote down vote up
public static void clearValueAnimator(ValueAnimator animator) {
    if (animator != null) {
        animator.removeAllListeners();
        animator.removeAllUpdateListeners();
        if (Build.VERSION.SDK_INT >= 19) {
            animator.pause();
        }
        animator.cancel();
    }
}
 
Example 4
Source File: PinchImageView.java    From UGank with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    //移动图像并给出结果
    boolean result = scrollBy(mVector[0], mVector[1]);
    //衰减速度
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    //速度太小或者不能移动了就结束
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
        animation.cancel();
    }
}
 
Example 5
Source File: PinchImageView.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    //移动图像并给出结果
    boolean result = scrollBy(mVector[0], mVector[1]);
    //衰减速度
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    //速度太小或者不能移动了就结束
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
        animation.cancel();
    }
}
 
Example 6
Source File: PinchImageView.java    From LLApp with Apache License 2.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    //移动图像并给出结果
    boolean result = scrollBy(mVector[0], mVector[1]);
    //衰减速度
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    //速度太小或者不能移动了就结束
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
        animation.cancel();
    }
}
 
Example 7
Source File: LoadingView.java    From TigerVideo with Apache License 2.0 5 votes vote down vote up
public void stop() {

            for(ValueAnimator valueAnimator : mBallAnimators) {
                valueAnimator.cancel();
            }
            for(Ball ball : mBalls) {
                ball.reset();
            }
        }
 
Example 8
Source File: PinchImageView.java    From Gank with Apache License 2.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    boolean result = scrollBy(mVector[0], mVector[1]);
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1) {
        animation.cancel();
    }
}
 
Example 9
Source File: PinchImageView.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    //移动图像并给出结果
    boolean result = scrollBy(mVector[0], mVector[1]);
    //衰减速度
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    //速度太小或者不能移动了就结束
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
        animation.cancel();
    }
}
 
Example 10
Source File: GeometricProgressView.java    From geometric-progress-view with Apache License 2.0 5 votes vote down vote up
private void cancelAnimation() {
    if (isInEditMode()) return;
    if (animators != null) {
        for (ValueAnimator valueAnimator : animators) {
            valueAnimator.cancel();
        }
        animators.clear();
        animators = null;
    }
}
 
Example 11
Source File: ExpandedScreen.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void applyShowActionBar(boolean show) {
	ActionBar actionBar = activity.getActionBar();
	if (fullScreenLayoutEnabled) {
		boolean showing = isActionBarShowing();
		ValueAnimator foregroundAnimator = ExpandedScreen.this.foregroundAnimator;
		if (foregroundAnimator != null) {
			foregroundAnimator.cancel();
		}
		if (showing != show) {
			if (toolbarView != null) {
				actionBar.show();
			}
			foregroundAnimator = ValueAnimator.ofFloat(show ? 0f : 1f, show ? 1f : 0f);
			ForegroundAnimatorListener listener = new ForegroundAnimatorListener(show);
			foregroundAnimator.setInterpolator(AnimationUtils.ACCELERATE_DECELERATE_INTERPOLATOR);
			foregroundAnimator.setDuration(ACTION_BAR_ANIMATION_TIME);
			foregroundAnimator.addListener(listener);
			foregroundAnimator.addUpdateListener(listener);
			foregroundAnimator.start();
			ExpandedScreen.this.foregroundAnimator = foregroundAnimator;
			foregroundAnimatorShow = show;
		}
	}
	if (toolbarView == null) {
		if (show) {
			actionBar.show();
		} else {
			actionBar.hide();
		}
	}
}
 
Example 12
Source File: SymbolActivity.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStop() {
  super.onStop();
  for (ValueAnimator animator : animators) {
    animator.cancel();
  }
  mapView.onStop();
}
 
Example 13
Source File: FoldLayout.java    From ListItemFold with MIT License 5 votes vote down vote up
void clearAnimations() {
    for (WeakReference<ValueAnimator> reference : this.animatorWeakHashMap) {
        ValueAnimator anim = reference.get();
        if (anim != null) {
            anim.cancel();
        }
    }
    this.animatorWeakHashMap.clear();
}
 
Example 14
Source File: ScanShapeView.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 动画开关统一方法
 * @param operate 动画操作
 */
private void animSwitch(int operate) {
    try {
        // 动画对象
        ValueAnimator valueAnimator = null;
        // 判断形状类型
        switch (mShapeType) {
            case Square: // 正方形
                valueAnimator = mAnimToSquare;
                break;
            case Hexagon: // 六边形
                valueAnimator = mAnimToHexagon;
                break;
            case Annulus: // 环形
                valueAnimator = mAnimToAnnulus;
                break;
        }
        if (valueAnimator != null) {
            switch (operate) {
                case START_ANIM:
                    valueAnimator.start();
                    break;
                case STOP_ANIM:
                    valueAnimator.cancel();
                    break;
            }
        }
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "animSwitch - " + mShapeType.name());
    }
}
 
Example 15
Source File: MediaSeekBar.java    From android-MediaBrowserService with Apache License 2.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(final ValueAnimator valueAnimator) {
    // If the user is changing the slider, cancel the animation.
    if (mIsTracking) {
        valueAnimator.cancel();
        return;
    }

    final int animatedIntValue = (int) valueAnimator.getAnimatedValue();
    setProgress(animatedIntValue);
}
 
Example 16
Source File: PinchImageView.java    From AcgClub with MIT License 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
  //移动图像并给出结果
  boolean result = scrollBy(mVector[0], mVector[1]);
  //衰减速度
  mVector[0] *= FLING_DAMPING_FACTOR;
  mVector[1] *= FLING_DAMPING_FACTOR;
  //速度太小或者不能移动了就结束
  if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
    animation.cancel();
  }
}
 
Example 17
Source File: PinchImageView.java    From leafpicrevived with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    //移动图像并给出结果
    boolean result = scrollBy(mVector[0], mVector[1]);
    //衰减速度
    mVector[0] *= FLING_DAMPING_FACTOR;
    mVector[1] *= FLING_DAMPING_FACTOR;
    //速度太小或者不能移动了就结束
    if (!result || MathUtils.getDistance(0, 0, mVector[0], mVector[1]) < 1f) {
        animation.cancel();
    }
}
 
Example 18
Source File: AnimationMatrix.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
void stop() {
  ValueAnimator animator = this.animator;
  if (animator != null) animator.cancel();
}
 
Example 19
Source File: SimpleExpandModel.java    From ExpandLayoutManager with Apache License 2.0 4 votes vote down vote up
void restartInner(final ValueAnimator progressAnimator) {
    progressAnimator.removeAllListeners();
    progressAnimator.cancel();
    startInner(progressAnimator);
}
 
Example 20
Source File: AnimationMatrix.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
void stop() {
  ValueAnimator animator = this.animator;
  if (animator != null) animator.cancel();
}