protected Animator createAnimatorOut(Config config) { return AnimatorInflater.loadAnimator(getContext(), config.animatorResId); }
private static void setViewStateListAnimator(View view, ViewNodeInfo viewNodeInfo) { StateListAnimator stateListAnimator = viewNodeInfo.getStateListAnimator(); final int stateListAnimatorRes = viewNodeInfo.getStateListAnimatorRes(); if (stateListAnimator == null && stateListAnimatorRes == 0) { return; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { throw new IllegalStateException( "MountState has a ViewNodeInfo with stateListAnimator, " + "however the current Android version doesn't support stateListAnimator on Views"); } if (stateListAnimator == null) { stateListAnimator = AnimatorInflater.loadStateListAnimator(view.getContext(), stateListAnimatorRes); } view.setStateListAnimator(stateListAnimator); }
protected Animator createAnimatorIn(Config config) { Animator animatorIn; if (config.animatorReverseResId == 0) { animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorResId); animatorIn.setInterpolator(new ReverseInterpolator()); } else { animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorReverseResId); } return animatorIn; }
/** * Ports {@link android.view.View#setStateListAnimator(android.animation.StateListAnimator)} * into components world. However, since the aforementioned view's method is available only on * API 21 and above, calling this method on lower APIs will have no effect. On the legit * versions, on the other hand, calling this method will lead to the component being wrapped * into a view */ public T stateListAnimatorRes(@DrawableRes int resId) { if (Build.VERSION.SDK_INT >= 26) { // We cannot do it on the versions prior to Android 8.0 since there is a possible race // condition when loading state list animators, thus we will avoid doing it off the UI // thread return stateListAnimator( AnimatorInflater.loadStateListAnimator(mContext.getAndroidContext(), resId)); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mComponent.getOrCreateCommonPropsHolder().stateListAnimatorRes(resId); } return getThis(); }
@Test public void shouldCreateAnimators() throws Exception { Animator animator = AnimatorInflater.loadAnimator(application, R.animator.spinning); assertThat(animator).isInstanceOf((Class<? extends Animator>) Animator.class); }
private void setStateListAnimator() { StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.anim_view_state_change_2); findViewById(R.id.view_puppet2).setStateListAnimator(stateListAnimator); }
public static void initAnimations(AnimatedView view, TypedArray a, int[] ids) { if (((View) view).isInEditMode()) return; int carbon_inAnimation = ids[0]; if (a.hasValue(carbon_inAnimation)) { TypedValue typedValue = new TypedValue(); a.getValue(carbon_inAnimation, typedValue); if (typedValue.resourceId != 0) { view.setInAnimator(AnimatorInflater.loadAnimator(((View) view).getContext(), typedValue.resourceId)); } else { view.setInAnimator(AnimUtils.Style.values()[typedValue.data].getInAnimator()); } } int carbon_outAnimation = ids[1]; if (a.hasValue(carbon_outAnimation)) { TypedValue typedValue = new TypedValue(); a.getValue(carbon_outAnimation, typedValue); if (typedValue.resourceId != 0) { view.setOutAnimator(AnimatorInflater.loadAnimator(((View) view).getContext(), typedValue.resourceId)); } else { view.setOutAnimator(AnimUtils.Style.values()[typedValue.data].getOutAnimator()); } } }
@Override public void setStateListAnimator(View view, int id) { view.setStateListAnimator(AnimatorInflater.loadStateListAnimator(view.getContext(), id)); } }
/** * use property animation by xml; * * @return */ private Animator getAnimationByXml() { final int height = mPuppet.getLayoutParams().height; final int width = mPuppet.getLayoutParams().width; AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset); //ValueAnimator usage:add AnimatorUpdateListener; ArrayList<Animator> childAnimations = animatorSet.getChildAnimations(); ((ValueAnimator) childAnimations.get(childAnimations.size() - 1)) .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); mPuppet.getLayoutParams().height = (int) (height * animatedValue); mPuppet.getLayoutParams().width = (int) (width * animatedValue); mPuppet.requestLayout(); } }); animatorSet.setTarget(mPuppet); return animatorSet; }
static void setStateListAnimatorFromAttrs(View view, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final Context context = view.getContext(); final TypedArray a = context.obtainStyledAttributes(attrs, STATE_LIST_ANIM_ATTRS, defStyleAttr, defStyleRes); try { if (a.hasValue(0)) { StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context, a.getResourceId(0, 0)); view.setStateListAnimator(sla); } } finally { a.recycle(); } }
(AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipHorizontalOutId); mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipHorizontalInId); } else { mSetRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipHorizontalRightOutId); mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipHorizontalRightInId); mSetTopOut = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipVerticalFrontOutId); mSetBottomIn = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipVerticalFrontInId); } else { mSetTopOut = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipVerticalOutId); mSetBottomIn = (AnimatorSet) AnimatorInflater.loadAnimator(this.context, animFlipVerticalInId);
private void setStateListAnimator() { StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.anim_view_state_change_2); findViewById(R.id.view_puppet2).setStateListAnimator(stateListAnimator); }
private Animator createAnimatorOut(Context context) { return AnimatorInflater.loadAnimator(context, mAnimatorResId); }
public FunnyButton(Context context) { super(context); setPreventCornerOverlap(false); setUseCompatPadding(true); setClickable(true); if (Build.VERSION.SDK_INT >= 21){ stateListAnimator = AnimatorInflater .loadStateListAnimator(context, R.anim.card_ripple_touch); setStateListAnimator(stateListAnimator); } setForeground(ContextCompat.getDrawable(context, R.drawable.card_ripple)); textView = new TextView(context); }
public AnimatorStrategyBuilder(Context context, int resourceIDIn, int resourceIDOut) { mAnimatorIn = (ObjectAnimator) AnimatorInflater.loadAnimator(context, resourceIDIn); mAnimatorOut = (ObjectAnimator) AnimatorInflater.loadAnimator(context, resourceIDOut); }
public FunnyButton(Context context, AttributeSet attrs) { super(context, attrs); setPreventCornerOverlap(false); setUseCompatPadding(true); setClickable(true); if (Build.VERSION.SDK_INT >= 21){ stateListAnimator = AnimatorInflater .loadStateListAnimator(context, R.anim.card_ripple_touch); setStateListAnimator(stateListAnimator); } setForeground(ContextCompat.getDrawable(context, R.drawable.card_ripple)); textView = new TextView(context); initButton(context, attrs); }
private Animator createAnimatorOut(Context context) { return AnimatorInflater.loadAnimator(context, mAnimatorResId); }
private Animator createAnimatorOut(Context context) { return AnimatorInflater.loadAnimator(context, mAnimatorResId); }
private Animator createAnimatorOut(Context context) { return AnimatorInflater.loadAnimator(context, mAnimatorResId); }
private Animator createAnimatorIn(Context context) { Animator animatorIn; if (mAnimatorReverseResId == 0) { animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId); animatorIn.setInterpolator(new ReverseInterpolator()); } else { animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId); } return animatorIn; }