android.animation.ObjectAnimator.cancel()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(274)

本文整理了Java中android.animation.ObjectAnimator.cancel()方法的一些代码示例,展示了ObjectAnimator.cancel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectAnimator.cancel()方法的具体详情如下:
包路径:android.animation.ObjectAnimator
类名称:ObjectAnimator
方法名:cancel

ObjectAnimator.cancel介绍

暂无

代码示例

代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout

/**
 * 停止动画
 */
public void cancelSunLineAnim() {
  if (mAnimator != null) {
    mAnimator.cancel();
  }
}

代码示例来源:origin: arimorty/floatingsearchview

private void cancelChildAnimListAndClear() {
  for (ObjectAnimator animator : anims) {
    animator.cancel();
  }
  anims.clear();
}

代码示例来源:origin: ZieIony/Carbon

@Override
  public void onAnimationStart(Animator animation) {
    for (WeakReference<ObjectAnimator> wa : sRunningAnimators) {
      ObjectAnimator a = wa.get();
      if (a == null) {
        continue;
      }
      if (hasSameTargetAndProperties(animator, a)) {
        a.cancel();
      }
    }
  }
});

代码示例来源:origin: naman14/Timber

private void showBubble() {
  AnimatorSet animatorSet = new AnimatorSet();
  bubble.setVisibility(VISIBLE);
  if (currentAnimator != null)
    currentAnimator.cancel();
  currentAnimator = ObjectAnimator.ofFloat(bubble, "alpha", 0f, 1f).setDuration(BUBBLE_ANIMATION_DURATION);
  currentAnimator.start();
}

代码示例来源:origin: naman14/Timber

private void hideBubble() {
  if (currentAnimator != null)
    currentAnimator.cancel();
  currentAnimator = ObjectAnimator.ofFloat(bubble, "alpha", 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
  currentAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      bubble.setVisibility(INVISIBLE);
      currentAnimator = null;
    }
    @Override
    public void onAnimationCancel(Animator animation) {
      super.onAnimationCancel(animation);
      bubble.setVisibility(INVISIBLE);
      currentAnimator = null;
    }
  });
  currentAnimator.start();
}

代码示例来源:origin: arcadefire/nice-spinner

@Override
protected void onDetachedFromWindow() {
  if (arrowAnimator != null) {
    arrowAnimator.cancel();
  }
  super.onDetachedFromWindow();
}

代码示例来源:origin: balysv/material-ripple

private void startHover() {
  if (eventCancelled) return;
  if (hoverAnimator != null) {
    hoverAnimator.cancel();
  }
  final float radius = (float) (Math.sqrt(Math.pow(getWidth(), 2) + Math.pow(getHeight(), 2)) * 1.2f);
  hoverAnimator = ObjectAnimator.ofFloat(this, radiusProperty, rippleDiameter, radius)
    .setDuration(HOVER_DURATION);
  hoverAnimator.setInterpolator(new LinearInterpolator());
  hoverAnimator.start();
}

代码示例来源:origin: seven332/EhViewer

private void hideSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mHideSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.hide();
    mShowSystemUi = false;
  }
}

代码示例来源:origin: seven332/EhViewer

private void showSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  sliderPanel.setTranslationY(sliderPanel.getHeight());
  sliderPanel.setVisibility(View.VISIBLE);
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mShowSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.show();
    mShowSystemUi = true;
  }
}

代码示例来源:origin: qiujuer/Genius-Android

private ObjectAnimator getTitleAnimator() {
  if (mAnimator == null) {
    if (mCurTitleProperty == null)
      mCurTitleProperty = new TitleProperty();
    mAnimator = ObjectAnimator.ofObject(this, TITLE_PROPERTY, new TitleEvaluator(mCurTitleProperty), mCurTitleProperty);
    mAnimator.setDuration(ANIMATION_DURATION);
    mAnimator.setInterpolator(ANIMATION_INTERPOLATOR);
  } else {
    mAnimator.cancel();
  }
  return mAnimator;
}

代码示例来源:origin: jiajunhui/PlayerBase

private void cancelTopAnimation(){
  if(mTopAnimator!=null){
    mTopAnimator.cancel();
    mTopAnimator.removeAllListeners();
    mTopAnimator.removeAllUpdateListeners();
  }
}

代码示例来源:origin: balysv/material-ripple

private void cancelAnimations() {
  if (rippleAnimator != null) {
    rippleAnimator.cancel();
    rippleAnimator.removeAllListeners();
  }
  if (hoverAnimator != null) {
    hoverAnimator.cancel();
  }
}

代码示例来源:origin: jiajunhui/PlayerBase

private void cancelBottomAnimation(){
  if(mBottomAnimator!=null){
    mBottomAnimator.cancel();
    mBottomAnimator.removeAllListeners();
    mBottomAnimator.removeAllUpdateListeners();
  }
}

代码示例来源:origin: xmuSistone/CardSlidePanel

public void setVisibilityWithAnimation(final int visibility, int delayIndex) {
    if (visibility == View.VISIBLE && getVisibility() != View.VISIBLE) {
      setAlpha(0);
      setVisibility(visibility);

      if (null != alphaAnimator) {
        alphaAnimator.cancel();
      }
      alphaAnimator = ObjectAnimator.ofFloat(this, "alpha",
          0.0f, 1.0f);
      alphaAnimator.setDuration(360);
      alphaAnimator.setStartDelay(delayIndex * 200);
      alphaAnimator.start();
    }
  }
}

代码示例来源:origin: xmuSistone/AndroidPileLayout

private void transitionSecene(int position) {
  if (transitionAnimator != null) {
    transitionAnimator.cancel();
  }
  countryView.saveNextPosition(position, dataList.get(position).getCountry() + "-" + position);
  temperatureView.saveNextPosition(position, dataList.get(position).getTemperature());
  addressView.saveNextPosition(position, dataList.get(position).getAddress());
  bottomView.saveNextPosition(position, dataList.get(position).getMapImageUrl());
  timeView.saveNextPosition(position, dataList.get(position).getTime());
  transitionAnimator = ObjectAnimator.ofFloat(this, "transitionValue", 0.0f, 1.0f);
  transitionAnimator.setDuration(300);
  transitionAnimator.start();
  transitionAnimator.addListener(animatorListener);
}

代码示例来源:origin: naman14/Timber

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  final int action = event.getAction();
  switch (action) {
    case MotionEvent.ACTION_DOWN:
      if (event.getX() < handle.getX())
        return false;
      if (currentAnimator != null)
        currentAnimator.cancel();
      if (bubble.getVisibility() == INVISIBLE)
        showBubble();
      handle.setSelected(true);
    case MotionEvent.ACTION_MOVE:
      final float y = event.getY();
      setBubbleAndHandlePosition(y);
      setRecyclerViewPosition(y);
      return true;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
      handle.setSelected(false);
      hideBubble();
      return true;
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: aa112901/remusic

public void translationToLeft() {
  if (mObjectAnimator != null) {
    mObjectAnimator.cancel();
    mObjectAnimator = null;
  }
  initTranlationAnimate(0, (int) (-getWidth() * 1.2));
  initTranlationAnimate1(getWidth(), 0);
}

代码示例来源:origin: aa112901/remusic

public void stopRotation() {
  if (mObjectAnimator != null) {
    if (mObjectAnimator.isRunning()) {
      mObjectAnimator.cancel();
    }
    float valueAvatar = (float) mObjectAnimator.getAnimatedValue();
    v = valueAvatar;
    mObjectAnimator.setFloatValues(valueAvatar, 360f + valueAvatar);
  } else {
    initRotateAnimation(0f);
  }
}

代码示例来源:origin: aa112901/remusic

public void translationToRight() {
  mObjectAnimator.cancel();
  mObjectAnimator = null;
  initRotateAnimation(0f);
  initTranlationAnimate(0, (int) (getWidth() * 1.2));
  initTranlationAnimate1(-getWidth(), 0);
}

代码示例来源:origin: aa112901/remusic

mRotateAnim.cancel();
float valueAvatar = (float) mRotateAnim.getAnimatedValue();
mRotateAnim.setFloatValues(valueAvatar, 360f + valueAvatar);

相关文章