androidx.annotation.AnimatorRes Java Examples

The following examples show how to use androidx.annotation.AnimatorRes. 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: MotionSpec.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** 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;
  }
}
 
Example #2
Source File: DynamicAnimUtils.java    From dynamic-utils with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #3
Source File: ResourceUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 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;
}
 
Example #4
Source File: DataLayout.java    From power-adapters with Apache License 2.0 5 votes vote down vote up
@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)));
}
 
Example #5
Source File: FabTransformationSheetBehavior.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: Config.java    From CircleIndicator with Apache License 2.0 4 votes vote down vote up
public Builder animatorReverse(@AnimatorRes int animatorReverseResId) {
    mConfig.animatorReverseResId = animatorReverseResId;
    return this;
}
 
Example #7
Source File: Config.java    From CircleIndicator with Apache License 2.0 4 votes vote down vote up
public Builder animator(@AnimatorRes int animatorResId) {
    mConfig.animatorResId = animatorResId;
    return this;
}
 
Example #8
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #9
Source File: FloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #10
Source File: FloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #11
Source File: ChipDrawable.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #12
Source File: ChipDrawable.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #13
Source File: Chip.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
  }
}
 
Example #14
Source File: Chip.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
  }
}
 
Example #15
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #16
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #17
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * 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));
}
 
Example #18
Source File: MotionStrategy.java    From material-components-android with Apache License 2.0 votes vote down vote up
@AnimatorRes int getDefaultMotionSpecResource();