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

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

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

ObjectAnimator.setAutoCancel介绍

暂无

代码示例

代码示例来源:origin: lyft/scissors

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
  static void autoCancel(ObjectAnimator objectAnimator) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
      objectAnimator.setAutoCancel(true);
    }
  }
}

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

public void setShape(boolean delete, long duration) {
  if (!((!delete && mProgress == 0f) || (delete && mProgress == 1f))) {
    float endProgress = delete ? 1f : 0f;
    if (duration <= 0) {
      setProgress(endProgress);
    } else {
      ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", endProgress);
      oa.setDuration(duration);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        oa.setAutoCancel(true);
      }
      oa.start();
    }
  }
}

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

public void setShape(boolean arrow, long duration) {
    if (!((!arrow && mProgress == 0f) || (arrow && mProgress == 1f))) {
      float endProgress = arrow ? 1f : 0f;
      if (duration <= 0) {
        setProgress(endProgress);
      } else {
        ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", endProgress);
        oa.setDuration(duration);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
          oa.setAutoCancel(true);
        }
        oa.start();
      }
    }
  }
}

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

oa.setAutoCancel(true);

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

private void hideImeAndSuggestionsList(boolean animation) {
  // Hide ime
  InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
  // Hide suggestions list
  if (animation) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", 0f);
    oa.setDuration(ANIMATE_TIME);
    oa.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    oa.addListener(new SimpleAnimatorListener() {
      @Override
      public void onAnimationStart(Animator animation) {
        mInAnimation = true;
      }
      @Override
      public void onAnimationEnd(Animator animation) {
        mListContainer.setVisibility(View.GONE);
        mInAnimation = false;
      }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      oa.setAutoCancel(true);
    }
    oa.start();
  } else {
    setProgress(0f);
    mListContainer.setVisibility(View.GONE);
  }
}

代码示例来源:origin: wooplr/Spotlight

lineAnim.addUpdateListener(this);
if (android.os.Build.VERSION.SDK_INT > 17) {
  lineAnim.setAutoCancel(true);

代码示例来源:origin: ganshenml/WebViewPageScannerApp

private void showLoadingAnimation() {
  centerIv.setVisibility(View.VISIBLE);
  centerIv.setImageResource(R.drawable.loading);
  if (objectAnimator == null) {
    objectAnimator = ObjectAnimator.ofFloat(centerIv, "rotation", 0f, 360f);
    objectAnimator.setDuration(2000);
    objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      objectAnimator.setAutoCancel(true);
    }
  }
  objectAnimator.start();
}

代码示例来源:origin: bq/MarkerSeekBar

/**
 * Show the popup and the marker. Add small delay to avoid taps showing the marker.
 * This action cancels if {@link #hideMarker(boolean, int)} (boolean, int)} is called.
 */
public void showMarker(boolean animated, int delay) {
  ObjectAnimator anim = ObjectAnimator.ofFloat(this, "markerAnimationFrame", markerAnimationFrame, 1);
  anim.setAutoCancel(true);
  anim.setInterpolator(ANIMATION_SHOW_INTERPOLATOR);
  anim.setDuration(animated ? ANIMATION_SHOW_DURATION : 0);
  anim.setStartDelay(delay);
  anim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationStart(Animator animation) {
      showPopUp();
    }
  });
  anim.start();
}

代码示例来源:origin: saki4510t/libcommon

@Override
  public void run() {
    target.setTag(R.id.anim_type, ANIMATION_FADE_OUT);    // フェードアウトの印
    target.setTag(R.id.anim_listener, listener);
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(1.0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 1f, 0f );
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isAndroid4_3())
      objectAnimator.setAutoCancel(true);		// API >= 18 同じターゲットに対して別のAnimatorが開始したら自分をキャンセルする
    objectAnimator.setDuration(duration > 0 ? duration : DEFAULT_DURATION_MS);
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0);	// 開始までの時間
    objectAnimator.start();                        // アニメーションを開始
  }
}, 100);

代码示例来源:origin: saki4510t/libcommon

@Override
  public void run() {
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIMATION_FADE_IN);    // フェードインの時の印
    target.setTag(R.id.anim_listener, listener);
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(0.0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 0f, 1f );
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
      objectAnimator.setAutoCancel(true);		// API >= 18 同じターゲットに対して別のAnimatorが開始したら自分をキャンセルする
    objectAnimator.setDuration(duration > 0 ? duration : DEFAULT_DURATION_MS);
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0);	// 開始までの時間
    objectAnimator.start();                        // アニメーションを開始
  }
}, 100);

代码示例来源:origin: bq/MarkerSeekBar

/**
 * Hide marker and dismiss the window.
 * This action cancels if {@link #showMarker(boolean, int)} is called.
 */
public void hideMarker(boolean animated, int delay) {
  ObjectAnimator anim = ObjectAnimator.ofFloat(this, "markerAnimationFrame", markerAnimationFrame, 0);
  anim.setAutoCancel(true);
  anim.setInterpolator(ANIMATION_HIDE_INTERPOLATOR);
  anim.setDuration(animated ? ANIMATION_HIDE_DURATION : 0);
  anim.setStartDelay(delay);
  anim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      hidePopUp();
    }
    @Override
    public void onAnimationCancel(Animator animation) {
      hidePopUp();
    }
  });
  anim.start();
}

代码示例来源:origin: saki4510t/libcommon

@Override
  public void run() {
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIMATION_ZOOM_IN);    // ズームインの時の印
    target.setTag(R.id.anim_listener, listener);
    target.setScaleX(0.0f);
    target.setScaleY(0.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat( "scaleX", 0.01f, 1f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat( "scaleY", 0.01f, 1f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
      objectAnimator.setAutoCancel(true);		// API >= 18 同じターゲットに対して別のAnimatorが開始したら自分をキャンセルする
    objectAnimator.setDuration(duration > 0 ? duration : DEFAULT_DURATION_MS);
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0);	// 開始までの時間
    objectAnimator.start();                        // アニメーションを開始
  }
}, 100);

代码示例来源:origin: saki4510t/libcommon

@Override
  public void run() {
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIMATION_ZOOM_OUT);    // ズームアウトの時の印
    target.setTag(R.id.anim_listener, listener);
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat( "scaleX", 1f, 0f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat( "scaleY", 1f, 0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
      objectAnimator.setAutoCancel(true);		// API >= 18 同じターゲットに対して別のAnimatorが開始したら自分をキャンセルする
    objectAnimator.setDuration(duration > 0 ? duration : DEFAULT_DURATION_MS);
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0);	// 開始までの時間
    objectAnimator.start();                        // アニメーションを開始
  }
}, 100);

代码示例来源:origin: NightscoutFoundation/xDrip

endTime = now + stagger;
alpha.setAutoCancel(true);

代码示例来源:origin: jamorham/xDrip-plus

endTime = now + stagger;
alpha.setAutoCancel(true);

代码示例来源:origin: google-ar/sceneform-android-sdk

/** Returns an ObjectAnimator that makes this node rotate. */
 private static ObjectAnimator createAnimator() {
  // Node's setLocalRotation method accepts Quaternions as parameters.
  // First, set up orientations that will animate a circle.
  Quaternion orientation1 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 0);
  Quaternion orientation2 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 120);
  Quaternion orientation3 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 240);
  Quaternion orientation4 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 360);

  ObjectAnimator orbitAnimation = new ObjectAnimator();
  orbitAnimation.setObjectValues(orientation1, orientation2, orientation3, orientation4);

  // Next, give it the localRotation property.
  orbitAnimation.setPropertyName("localRotation");

  // Use Sceneform's QuaternionEvaluator.
  orbitAnimation.setEvaluator(new QuaternionEvaluator());

  //  Allow orbitAnimation to repeat forever
  orbitAnimation.setRepeatCount(ObjectAnimator.INFINITE);
  orbitAnimation.setRepeatMode(ObjectAnimator.RESTART);
  orbitAnimation.setInterpolator(new LinearInterpolator());
  orbitAnimation.setAutoCancel(true);

  return orbitAnimation;
 }
}

相关文章