类androidx.annotation.AnimatorRes源码实例Demo

下面列出了怎么用androidx.annotation.AnimatorRes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: material-components-android   文件: MotionSpec.java
/** Inflates an instance of MotionSpec from the given animator resource. */
@Nullable
public static MotionSpec createFromResource(@NonNull Context context, @AnimatorRes int id) {
  try {
    Animator animator = AnimatorInflater.loadAnimator(context, id);
    if (animator instanceof AnimatorSet) {
      AnimatorSet set = (AnimatorSet) animator;
      return createSpecFromAnimators(set.getChildAnimations());
    } else if (animator != null) {
      List<Animator> animators = new ArrayList<>();
      animators.add(animator);
      return createSpecFromAnimators(animators);
    } else {
      return null;
    }
  } catch (Exception e) {
    Log.w(TAG, "Can't load animation resource ID #0x" + Integer.toHexString(id), e);
    return null;
  }
}
 
源代码2 项目: DevUtils   文件: ResourceUtils.java
/**
 * 获取 Animation
 * @param id resource identifier
 * @return XmlResourceParser
 */
public static XmlResourceParser getAnimation(@AnimatorRes @AnimRes final int id) {
    try {
        return DevUtils.getContext().getResources().getAnimation(id);
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getAnimation");
    }
    return null;
}
 
源代码3 项目: dynamic-utils   文件: DynamicAnimUtils.java
/**
 * Play an animator animation on a view.
 *
 * @param view The view to play the animation.
 * @param animator The animator to be applied on the view.
 */
public static void playAnimation(@NonNull View view, @AnimatorRes int animator) {
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater
            .loadAnimator(view.getContext(), animator);
    animatorSet.setTarget(view);

    animatorSet.start();
}
 
@NonNull
@Override
protected FabTransformationSpec onCreateMotionSpec(Context context, boolean expanded) {
  @AnimatorRes int specRes;
  if (expanded) {
    specRes = R.animator.mtrl_fab_transformation_sheet_expand_spec;
  } else {
    specRes = R.animator.mtrl_fab_transformation_sheet_collapse_spec;
  }

  FabTransformationSpec spec = new FabTransformationSpec();
  spec.timings = MotionSpec.createFromResource(context, specRes);
  spec.positioning = new Positioning(Gravity.CENTER, 0f, 0f);
  return spec;
}
 
源代码5 项目: power-adapters   文件: DataLayout.java
@Nullable
private static Animator loadAnimator(@NonNull Context context,
                                     @NonNull TypedArray typedArray,
                                     int index,
                                     int fallbackIndex,
                                     @AnimatorRes int defaultValue) {
    return AnimatorInflater.loadAnimator(context,
            typedArray.getResourceId(index, typedArray.getResourceId(fallbackIndex, defaultValue)));
}
 
源代码6 项目: CircleIndicator   文件: Config.java
public Builder animator(@AnimatorRes int animatorResId) {
    mConfig.animatorResId = animatorResId;
    return this;
}
 
源代码7 项目: CircleIndicator   文件: Config.java
public Builder animatorReverse(@AnimatorRes int animatorReverseResId) {
    mConfig.animatorReverseResId = animatorReverseResId;
    return this;
}
 
/**
 * Updates the motion spec for the show animation.
 *
 * @attr ref com.google.android.material.R.styleable#ExtendedFloatingActionButton_showMotionSpec
 */
public void setShowMotionSpecResource(@AnimatorRes int id) {
  setShowMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
/**
 * Updates the motion spec for the hide animation.
 *
 * @attr ref com.google.android.material.R.styleable#ExtendedFloatingActionButton_hideMotionSpec
 */
public void setHideMotionSpecResource(@AnimatorRes int id) {
  setHideMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
/**
 * Updates the motion spec for the extend animation.
 *
 * @attr ref com.google.android.material.R.styleable#ExtendedFloatingActionButton_extendMotionSpec
 */
public void setExtendMotionSpecResource(@AnimatorRes int id) {
  setExtendMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
/**
 * Updates the motion spec for the shrink animation.
 *
 * @attr ref com.google.android.material.R.styleable#ExtendedFloatingActionButton_shrinkMotionSpec
 */
public void setShrinkMotionSpecResource(@AnimatorRes int id) {
  setShrinkMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
/**
 * Updates the motion spec for the show animation.
 *
 * @attr ref com.google.android.material.R.styleable#FloatingActionButton_showMotionSpec
 */
public void setShowMotionSpecResource(@AnimatorRes int id) {
  setShowMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
/**
 * Updates the motion spec for the hide animation.
 *
 * @attr ref com.google.android.material.R.styleable#FloatingActionButton_hideMotionSpec
 */
public void setHideMotionSpecResource(@AnimatorRes int id) {
  setHideMotionSpec(MotionSpec.createFromResource(getContext(), id));
}
 
源代码14 项目: material-components-android   文件: ChipDrawable.java
/**
 * Sets this chip's show motion spec using a resource id.
 *
 * @param id The resource id of this chip's show motion spec.
 * @attr ref com.google.android.material.R.styleable#Chip_showMotionSpec
 */
public void setShowMotionSpecResource(@AnimatorRes int id) {
  setShowMotionSpec(MotionSpec.createFromResource(context, id));
}
 
源代码15 项目: material-components-android   文件: ChipDrawable.java
/**
 * Sets this chip's hide motion spec using a resource id.
 *
 * @param id The resource id of this chip's hide motion spec.
 * @attr ref com.google.android.material.R.styleable#Chip_hideMotionSpec
 */
public void setHideMotionSpecResource(@AnimatorRes int id) {
  setHideMotionSpec(MotionSpec.createFromResource(context, id));
}
 
源代码16 项目: material-components-android   文件: Chip.java
/**
 * Sets this chip's show motion spec using a resource id.
 *
 * @param id The resource id of this chip's show motion spec.
 * @attr ref com.google.android.material.R.styleable#Chip_showMotionSpec
 */
public void setShowMotionSpecResource(@AnimatorRes int id) {
  if (chipDrawable != null) {
    chipDrawable.setShowMotionSpecResource(id);
  }
}
 
源代码17 项目: material-components-android   文件: Chip.java
/**
 * Sets this chip's hide motion spec using a resource id.
 *
 * @param id The resource id of this chip's hide motion spec.
 * @attr ref com.google.android.material.R.styleable#Chip_hideMotionSpec
 */
public void setHideMotionSpecResource(@AnimatorRes int id) {
  if (chipDrawable != null) {
    chipDrawable.setHideMotionSpecResource(id);
  }
}
 
@AnimatorRes int getDefaultMotionSpecResource();