List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java
private void setupAnimators() { AnimatorSet set = new AnimatorSet(); for (int i = 0; i < mSpinnerCount; i++) { final int index = i; final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE); sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR); sweepAnimator.setDuration(mSweepAnimatorDuration); sweepAnimator.setRepeatMode(ValueAnimator.RESTART); sweepAnimator.setRepeatCount(ValueAnimator.INFINITE); sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY); sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*w w w. j a va 2s. c o m*/ public void onAnimationUpdate(ValueAnimator animation) { mSpinners[index].sweepAngle = (float) animation.getAnimatedValue(); mSpinners[index].updatePath(); invalidateSelf(); } }); sweepAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360; mSpinners[index].updatePath(); } }); set.playTogether(sweepAnimator); } mSweepAnimator = set; mAngleAnimator = ValueAnimator.ofFloat(0, 360); mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR); mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE); mAngleAnimator.setRepeatMode(ValueAnimator.RESTART); mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION); mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mGlobalAngle = (float) animation.getAnimatedValue(); updatePath(); invalidateSelf(); } }); }
From source file:com.hippo.android.animator.AnimatorsBase.java
static Animator playSequentially(List<Animator> animators) { if (animators == null || animators.size() == 0) { return null; }/*from w w w . j a va 2 s .co m*/ AnimatorSet set = null; Animator previous = null; for (Animator animator : animators) { if (animator == null) { continue; } if (previous == null) { // Save first non-null animator as previous previous = animator; } else { if (set == null) { set = new AnimatorSet(); } set.play(previous).before(animator); // Update previous previous = animator; } } return set == null ? previous : set; }
From source file:com.reddyetwo.hashmypass.app.TutorialIntroFragment.java
private void startAnimation() { // Load and set up individual animators AnimatorSet websiteAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_website);//from w ww .j ava2 s .c om websiteAnimator.setTarget(mWebsiteTextView); AnimatorSet masterKeyAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_master_key); masterKeyAnimator.setTarget(mIcMasterKeyView); AnimatorSet passwordAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_password); passwordAnimator.setTarget(mWebsitePasswordView); // Prepare set with all animators, set up repeating and random data mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(websiteAnimator, masterKeyAnimator, passwordAnimator); mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { generateRandomData(); } @Override public void onAnimationEnd(Animator animation) { if (mAnimatorSet != null) { mAnimatorSet.start(); } } }); mAnimatorSet.start(); }
From source file:com.crust87.centercropvideoviewsample.LoadImageTask.java
private static void fadeInView(View view) { ObjectAnimator fadeIn = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1f); fadeIn.setDuration(500);//from w w w .j ava2 s . c o m AnimatorSet fadeSet = new AnimatorSet(); fadeSet.play(fadeIn); fadeSet.start(); }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;// ww w.j av a 2 s. com if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:com.google.android.apps.muzei.TutorialFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { view.findViewById(R.id.tutorial_icon_affordance).setOnClickListener(new View.OnClickListener() { @Override//w w w .j a v a 2 s.co m public void onClick(View view) { FirebaseAnalytics.getInstance(getContext()).logEvent(FirebaseAnalytics.Event.TUTORIAL_COMPLETE, null); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); sp.edit().putBoolean(PREF_SEEN_TUTORIAL, true).apply(); } }); if (savedInstanceState == null) { float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); View mainTextView = view.findViewById(R.id.tutorial_main_text); mainTextView.setAlpha(0); mainTextView.setTranslationY(-animateDistance / 5); View subTextView = view.findViewById(R.id.tutorial_sub_text); subTextView.setAlpha(0); subTextView.setTranslationY(-animateDistance / 5); final View affordanceView = view.findViewById(R.id.tutorial_icon_affordance); affordanceView.setAlpha(0); affordanceView.setTranslationY(animateDistance); View iconTextView = view.findViewById(R.id.tutorial_icon_text); iconTextView.setAlpha(0); iconTextView.setTranslationY(animateDistance); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(500); mAnimator.setDuration(250); mAnimator.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f)); mAnimator.start(); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(2000); // Bug in older versions where set.setInterpolator didn't work Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0); ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); a3.setInterpolator(interpolator); a4.setInterpolator(interpolator); mAnimator.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (isAdded()) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } } }); } mAnimator.start(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } }
From source file:com.reddyetwo.hashmypass.app.tutorial.TutorialIntroFragment.java
private void createAnimation() { // Load and set up individual animators AnimatorSet websiteAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_website);//from w ww .j a va 2 s . com websiteAnimator.setTarget(mWebsiteTextView); AnimatorSet masterKeyAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_master_key); masterKeyAnimator.setTarget(mIcMasterKeyView); AnimatorSet passwordAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.intro_password); passwordAnimator.setTarget(mWebsitePasswordView); // Prepare set with all animators, set up repeating and random data mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(websiteAnimator, masterKeyAnimator, passwordAnimator); mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mAnimationCancelled = false; generateRandomData(); } @Override public void onAnimationCancel(Animator animation) { mAnimationCancelled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mAnimationCancelled) { mAnimatorSet.start(); } } }); }
From source file:despotoski.nikola.github.com.bottomnavigationlayout.Util.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void playTogether(Animator... animators) { AnimatorSet set = new AnimatorSet(); set.playTogether(animators);//from ww w . j a va 2 s . c om set.start(); }
From source file:org.videolan.vlc.gui.view.FastScroller.java
private void showBubble() { AnimatorSet animatorSet = new AnimatorSet(); bubble.setPivotX(bubble.getWidth()); bubble.setPivotY(bubble.getHeight()); bubble.setVisibility(VISIBLE);//from w w w.ja va2 s.c o m Animator growerX = ObjectAnimator.ofFloat(bubble, SCALE_X, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION); Animator growerY = ObjectAnimator.ofFloat(bubble, SCALE_Y, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION); Animator alpha = ObjectAnimator.ofFloat(bubble, ALPHA, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION); animatorSet.playTogether(growerX, growerY, alpha); animatorSet.start(); }
From source file:org.muckebox.android.ui.activity.WizardActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wizard); mExtraContainer = findViewById(R.id.wizard_extra_container); mExtraContainer.measure(SPEC, SPEC); mExtraContainerHeight = mExtraContainer.getMeasuredHeight(); LayoutParams params = mExtraContainer.getLayoutParams(); params.height = 0;/*from w w w. ja v a2s . c om*/ mExtraContainer.setLayoutParams(params); mExpandButton = findViewById(R.id.wizard_expand_button); mExpandButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play( ValueAnimator.ofObject(new HeightEvaluator(mExtraContainer), 0, mExtraContainerHeight)); animatorSet.play( ValueAnimator.ofObject(new HeightEvaluator(mExpandButton), mExpandButton.getHeight(), 0)); animatorSet.start(); } }); mServerText = (TextView) findViewById(R.id.wizard_server_text); mPasswordText = (TextView) findViewById(R.id.wizard_server_password); mPortText = (TextView) findViewById(R.id.wizard_port_text); mSslCheckbox = (CheckBox) findViewById(R.id.wizard_ssl_enabled); mResultText = (TextView) findViewById(R.id.wizard_result_text); readFromPreferences(); }