public void configureIndicator(int indicatorWidth, int indicatorHeight, int indicatorMargin, @AnimatorRes int animatorId, @AnimatorRes int animatorReverseId, @DrawableRes int indicatorBackgroundId, @DrawableRes int indicatorUnselectedBackgroundId) { mIndicatorWidth = indicatorWidth; mIndicatorHeight = indicatorHeight; mIndicatorMargin = indicatorMargin; mAnimatorResId = animatorId; mAnimatorReverseResId = animatorReverseId; mIndicatorBackgroundResId = indicatorBackgroundId; mIndicatorUnselectedBackgroundResId = indicatorUnselectedBackgroundId; checkIndicatorConfig(getContext()); }
/** Inflates an instance of MotionSpec from the given animator resource. */ @Nullable public static MotionSpec createFromResource(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; } }
public void configureIndicator(int indicatorWidth, int indicatorHeight, int indicatorMargin, @AnimatorRes int animatorId, @AnimatorRes int animatorReverseId, @DrawableRes int indicatorBackgroundId, @DrawableRes int indicatorUnselectedBackgroundId) { mIndicatorWidth = indicatorWidth; mIndicatorHeight = indicatorHeight; mIndicatorMargin = indicatorMargin; mAnimatorResId = animatorId; mAnimatorReverseResId = animatorReverseId; mIndicatorBackgroundResId = indicatorBackgroundId; mIndicatorUnselectedBackgroundResId = indicatorUnselectedBackgroundId; }
@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; }
protected HandleAnimationManager(View handle, @AnimatorRes int grabAnimator, @AnimatorRes int releaseAnimator) { if (grabAnimator != -1) { this.grabAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(handle.getContext(), grabAnimator); this.grabAnimator.setTarget(handle); } if (releaseAnimator != -1) { this.releaseAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(handle.getContext(), releaseAnimator); this.releaseAnimator.setTarget(handle); } }
public Builder setIconAnimation(@AnimatorRes int iconAnimation) { params.iconAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(context, iconAnimation); return this; }
public void setLoadingAnim(@AnimatorRes int animId) { mLoadingAnim = AnimatorInflater.loadAnimator(getContext(), animId); }
/** */ @Override @AnimatorRes public int getIncomingAnimation() { return mInAnimRes; }
/** */ @Override @AnimatorRes public int getOutgoingAnimation() { return mOutAnimRes; }
/** */ @Override @AnimatorRes public int getIncomingBackStackAnimation() { return mInBackAnimRes; }
/** */ @Override @AnimatorRes public int getOutgoingBackStackAnimation() { return mOutBackAnimRes; }
public void setShowMotionSpecResource(@AnimatorRes int id) { setShowMotionSpec(MotionSpec.createFromResource(context, id)); }
public void setHideMotionSpecResource(@AnimatorRes int id) { setHideMotionSpec(MotionSpec.createFromResource(context, id)); }
public void setShowMotionSpecResource(@AnimatorRes int id) { if (chipDrawable != null) { chipDrawable.setShowMotionSpecResource(id); } }
public void setHideMotionSpecResource(@AnimatorRes int id) { if (chipDrawable != null) { chipDrawable.setHideMotionSpecResource(id); } }
@AnimatorRes public int getInAnimationId() { return in; }
@AnimatorRes public int getOutAnimationId() { return out; }
public Builder withGrabAnimator(@AnimatorRes int grabAnimator) { this.grabAnimator = grabAnimator; return this; }
public Builder withReleaseAnimator(@AnimatorRes int releaseAnimator) { this.releaseAnimator = releaseAnimator; return this; }
public AbsBuilder<T> withShowAnimator(@AnimatorRes int showAnimatorResource){ this.showAnimatorResource = showAnimatorResource; return this; }
public AbsBuilder<T> withHideAnimator(@AnimatorRes int hideAnimatorResource){ this.hideAnimatorResource = hideAnimatorResource; return this; }
/** * Creates a new instance of BasicFragmentTransition with the specified animations and name. * * @param inAnim A resource id of the animation for an incoming fragment. * @param outAnim A resource id of the animation for an outgoing fragment to be added to the * back stack or to be destroyed and replaced by the incoming one. * @param inBackAnim A resource id of the animation for an incoming fragment to be showed from * the back stack. * @param outBackAnim A resource id of the animation for an outgoing fragment to be destroyed and * replaced by the incoming one. * @param name Name for the new transition. */ public BasicFragmentTransition(@AnimatorRes final int inAnim, @AnimatorRes final int outAnim, @AnimatorRes final int inBackAnim, @AnimatorRes final int outBackAnim, @NonNull final String name) { this.mInAnimRes = inAnim; this.mOutAnimRes = outAnim; this.mInBackAnimRes = inBackAnim; this.mOutBackAnimRes = outBackAnim; this.mName = name; }
/** * Set specific animation resources to run for the fragments that are * entering and exiting in this transaction. These animations will not be * played when popping the back stack. */ public abstract ExtraTransaction setCustomAnimations(@AnimatorRes @AnimRes int targetFragmentEnter, @AnimatorRes @AnimRes int currentFragmentPopExit);
/** * Set specific animation resources to run for the fragments that are * entering and exiting in this transaction. The <code>currentFragmentPopEnter</code> * and <code>targetFragmentExit</code> animations will be played for targetFragmentEnter/currentFragmentPopExit * operations specifically when popping the back stack. */ public abstract ExtraTransaction setCustomAnimations(@AnimatorRes @AnimRes int targetFragmentEnter, @AnimatorRes @AnimRes int currentFragmentPopExit, @AnimatorRes @AnimRes int currentFragmentPopEnter, @AnimatorRes @AnimRes int targetFragmentExit);
/** * Same as {@link #BasicFragmentTransition(int, int, int, int)} with back-stack animations set * to {@link #NO_ANIMATION}. */ public BasicFragmentTransition(@AnimatorRes final int inAnim, @AnimatorRes final int outAnim) { this(inAnim, outAnim, NO_ANIMATION, NO_ANIMATION); }
/** * Same as {@link #BasicFragmentTransition(int, int, int, int, String)} with name specified * as {@code "UNSPECIFIED"}. */ public BasicFragmentTransition(@AnimatorRes final int inAnim, @AnimatorRes final int outAnim, @AnimatorRes final int inBackAnim, @AnimatorRes final int outBackAnim) { this(inAnim, outAnim, inBackAnim, outBackAnim, "UNSPECIFIED"); }
/** * Returns the animation resource for a new incoming fragment. * * @return Animation resource or {@link #NO_ANIMATION} if no animation should be played for * incoming fragment. */ @AnimatorRes int getIncomingAnimation();
/** * Returns the animation resource for the current outgoing fragment. * * @return Animation resource or {@link #NO_ANIMATION} if no animation should be played for * outgoing fragment. */ @AnimatorRes int getOutgoingAnimation();