List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.dk.animation.effect.out.HingeOut.java
@Override public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) { ViewCompat.animate(holder.itemView).cancel(); AnimatorSet set = new AnimatorSet(); View target = holder.itemView; int abs = Math.random() > 0.5 ? -1 : 1; float x, y;/*from w w w . j a v a 2 s. c om*/ if (abs > 0) { x = target.getPaddingLeft(); y = target.getPaddingTop(); } else { x = target.getWidth(); y = target.getPaddingTop(); } set.setDuration(animator.getRemoveDuration()); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { animator.dispatchAddFinished(holder); animator.mAddAnimations.remove(holder); animator.dispatchFinishedWhenDone(); } @Override public void onAnimationCancel(Animator animation) { } }); set.playTogether( ObjectAnimator.ofFloat(target, "rotation", 0, abs * 80, abs * 60, abs * 80, abs * 60, abs * 60), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y)); set.setStartDelay(mDelay * mDelayCount); set.setDuration(animator.getAddDuration()); set.start(); animator.mAddAnimations.add(holder); }
From source file:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java
@NonNull @Override/*from w ww. j a v a 2 s .c om*/ protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the from view is a CountryDetailView if (from == null || !(from instanceof CountryDetailView)) throw new IllegalArgumentException("The from view must be a CountryDetailView"); if (to == null) throw new IllegalArgumentException("The to view must not be null"); final CountryDetailView detailView = (CountryDetailView) from; AnimatorSet animatorSet = new AnimatorSet(); // Set the to View's alpha to 0 to hide it at the beginning. to.setAlpha(0); // Scale down to hide the fab button PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); Animator hideFabButtonAnimator = ObjectAnimator.ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY); // Slide up the flag Animator flagAnimator = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, 0, -detailView.flagView.getHeight()); // Slide down the details Animator detailAnimator = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, 0, detailView.detailGroup.getHeight()); // Show the new view Animator showToViewAnimator = ObjectAnimator.ofFloat(to, View.ALPHA, 0, 1); animatorSet.playTogether(hideFabButtonAnimator, flagAnimator, detailAnimator, showToViewAnimator); animatorSet.setDuration(300); animatorSet.setInterpolator(new FastOutLinearInInterpolator()); animatorSet.start(); return animatorSet; }
From source file:net.huannguyen.conductorexample.transition.DetailPushAnimChangeHandler.java
@NonNull @Override/*from w w w . j av a 2 s .c om*/ protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the to view is a CountryDetailView if (to == null || !(to instanceof CountryDetailView)) throw new IllegalArgumentException("The to view must be a CountryDetailView"); final CountryDetailView detailView = (CountryDetailView) to; // Set the button scale to 0 to make it invisible at the beginning. detailView.favouriteFab.setScaleX(0); detailView.favouriteFab.setScaleY(0); AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet flagAndDetailAnim = new AnimatorSet(); // Hide the old view Animator hideFromViewAnim = ObjectAnimator.ofFloat(from, View.ALPHA, 1, 0); // Slide down the flag Animator flagAnim = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, -detailView.flagView.getHeight(), 0); // Slide up the details Animator detailAnim = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, detailView.detailGroup.getHeight(), 0); flagAndDetailAnim.playTogether(hideFromViewAnim, flagAnim, detailAnim); flagAndDetailAnim.setDuration(300); flagAndDetailAnim.setInterpolator(new FastOutSlowInInterpolator()); // Scale up the favourite fab PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0, 1); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0, 1); Animator favouriteAnim = ObjectAnimator .ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY).setDuration(200); animatorSet.playSequentially(flagAndDetailAnim, favouriteAnim); animatorSet.start(); return animatorSet; }
From source file:org.deviceconnect.android.deviceplugin.linking.setting.fragment.LinkingHelpFragment.java
private void createAnimation(final View v) { float size = 12.0f * getResources().getDisplayMetrics().density; long time = 1000; List<Animator> animatorList = new ArrayList<>(); ObjectAnimator fadeIn = ObjectAnimator.ofFloat(v, "translationY", -size, 0); fadeIn.setDuration(time);// ww w . j av a 2 s . co m animatorList.add(fadeIn); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(v, "translationY", 0, -size); fadeOut.setDuration(time); animatorList.add(fadeOut); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playSequentially(animatorList); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (!mDestroy) { animation.start(); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); }
From source file:com.hippo.android.animator.AnimatorsBase.java
static Animator playTogether(Collection<Animator> animators) { if (animators == null || animators.size() == 0) { return null; }/* w ww . j a va 2 s .c om*/ Animator first = null; AnimatorSet set = null; AnimatorSet.Builder builder = null; for (Animator animator : animators) { if (animator == null) { continue; } if (first == null) { // Save first non-null animator first = animator; } else { if (builder == null) { // Get second non-null animator // It's time to create a AnimatorSet set = new AnimatorSet(); builder = set.play(first); } builder.with(animator); } } return set == null ? first : set; }
From source file:com.google.android.apps.muzei.util.AnimatedMuzeiLogoFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { mSubtitleView = view.findViewById(R.id.logo_subtitle); mLogoView = (AnimatedMuzeiLogoView) view.findViewById(R.id.animated_logo); mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() { @Override/*from w ww . j av a2 s . c om*/ public void onStateChange(int state) { if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) { mSubtitleView.setAlpha(0); mSubtitleView.setVisibility(View.VISIBLE); mSubtitleView.setTranslationY(-mSubtitleView.getHeight()); // Bug in older versions where set.setInterpolator didn't work AnimatorSet set = new AnimatorSet(); Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); set.setDuration(500).playTogether(a1, a2, a3); set.start(); if (mOnFillStartedCallback != null) { mOnFillStartedCallback.run(); } } } }); if (savedInstanceState == null) { reset(); } }
From source file:io.jawg.osmcontributor.ui.adapters.OfflineRegionsAdapter.java
@Override public void onBindViewHolder(final OfflineRegionHolder holder, final int position) { OfflineRegionItem region = offlineRegions.get(position); String regionName = OfflineRegionManager.decodeRegionName(region.getOfflineRegion().getMetadata()); holder.offlineRegionTextView.setText(regionName); if (region.isSelected()) { Animator animX = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_X, 1.15f); Animator animY = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_Y, 1.15f); AnimatorSet animSet = new AnimatorSet(); animSet.playTogether(animX, animY); animSet.start();/*from w w w.j a v a2 s.com*/ } else { Animator animX = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_X, 1.0f); Animator animY = ObjectAnimator.ofFloat(holder.cardView, View.SCALE_Y, 1.0f); AnimatorSet animSet = new AnimatorSet(); animSet.playTogether(animX, animY); animSet.start(); } if (region.getStatus().isComplete()) { holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimaryDark)); holder.offlineRegionTextView.setTextColor(Color.WHITE); } else { holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.active_text)); holder.offlineRegionTextView.setTextColor(ContextCompat.getColor(context, R.color.disable_text)); } }
From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java
@Override public Animator onAnimateChange(List<Object> payloads, int fromLeft, int fromTop, int fromRight, int fromBottom, long duration) { if (payloads == null || payloads.isEmpty()) { return null; }/*from www.j a va2 s. co m*/ final AnimatorSet animatorSet = new AnimatorSet(); if (arrow != null) { animatorSet.playTogether( AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom, itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()), ObjectAnimator.ofFloat(arrow, TRANSLATION_Y, 0f)); } else { animatorSet.playTogether(AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom, itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom())); } animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { setTranslationY(0f); itemView.requestLayout(); } }); animatorSet.setDuration(duration); animatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); return animatorSet; }
From source file:io.vit.vitio.Settings.ComingSoonActivity.java
private void toggleCircle(ImageView imon, ImageView imoff[]) { imon.setActivated(true);//from w w w . j a va 2s .co m ObjectAnimator animatorX = ObjectAnimator.ofFloat(imon, "scaleX", 0.5f, 1.0f); ObjectAnimator animatorY = ObjectAnimator.ofFloat(imon, "scaleY", 0.5f, 1.0f); animatorX.setDuration(300); animatorY.setDuration(300); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animatorX, animatorY); animatorSet.start(); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics())); params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13, getResources().getDisplayMetrics()), 0); imon.setLayoutParams(params); for (int i = 0; i < imoff.length; i++) { imoff[i].setActivated(false); params = new LinearLayout.LayoutParams( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics())); params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13, getResources().getDisplayMetrics()), 0); imoff[i].setLayoutParams(params); } }
From source file:com.google.samples.apps.topeka.widget.TextResizeTransition.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (startValues == null || endValues == null) { return null; }/*ww w . j a v a 2 s. co m*/ float initialTextSize = (float) startValues.values.get(PROPERTY_NAME_TEXT_RESIZE); float targetTextSize = (float) endValues.values.get(PROPERTY_NAME_TEXT_RESIZE); TextView targetView = (TextView) endValues.view; targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize); int initialPaddingStart = (int) startValues.values.get(PROPERTY_NAME_PADDING_RESIZE); int targetPaddingStart = (int) endValues.values.get(PROPERTY_NAME_PADDING_RESIZE); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(targetView, ViewUtils.PROPERTY_TEXT_SIZE, initialTextSize, targetTextSize), ObjectAnimator.ofInt(targetView, ViewUtils.PROPERTY_TEXT_PADDING_START, initialPaddingStart, targetPaddingStart)); return animatorSet; }