List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:io.github.carlorodriguez.morningritual.MainActivity.java
private ObjectAnimator setAnimation(final ProgressBar progressBar, final TextView title, final TextView quote, final MorningRitual morningRitual, final FloatingActionButton fab) { final ObjectAnimator animator = ObjectAnimator.ofInt(progressBar, "progress", 0, 200000); animator.setDuration(getStepDurationInMillis(morningRitual)); animator.setInterpolator(new LinearInterpolator()); animator.addListener(new Animator.AnimatorListener() { @Override/* w w w . ja v a2 s.c o m*/ public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { notifyStepFinish(); morningRitual.nextStep(); setNextMorningRitualStep(progressBar, title, quote, morningRitual, fab); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); return animator; }
From source file:com.google.android.apps.santatracker.village.Village.java
private void easterEggInteraction() { mCallback.playSoundOnce(R.raw.easter_egg); // Fade into the distance ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 1.0f, 0f); anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION); anim.addListener(new Animator.AnimatorListener() { @Override// www. j a v a 2s.c o m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mImageUfo.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.start(); }
From source file:org.codeforafrica.citizenreporter.eNCA.widgets.SlidingTabLayout.java
public void setBadge(int position, boolean isBadged) { final View badgeView = mTabStrip.findViewWithTag(makeBadgeTag(position)); if (badgeView == null) { return;// w w w . jav a 2s. c o m } boolean wasBadged = (badgeView.getVisibility() == View.VISIBLE); if (isBadged == wasBadged) { return; } float start = isBadged ? 0f : 1f; float end = isBadged ? 1f : 0f; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, start, end); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, start, end); ObjectAnimator animScale = ObjectAnimator.ofPropertyValuesHolder(badgeView, scaleX, scaleY); if (isBadged) { animScale.setInterpolator(new BounceInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { badgeView.setVisibility(View.VISIBLE); } }); } else { animScale.setInterpolator(new AccelerateInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { badgeView.setVisibility(View.GONE); } }); } animScale.start(); }
From source file:de.blinkt.openvpn.fragments.LogFragment.java
private void showHideOptionsPanel() { boolean optionsVisible = (mOptionsLayout.getVisibility() != View.GONE); ObjectAnimator anim; if (optionsVisible) { anim = ObjectAnimator.ofFloat(mOptionsLayout, "alpha", 1.0f, 0f); anim.addListener(collapseListener); } else {/*from ww w . ja v a2 s .c o m*/ mOptionsLayout.setVisibility(View.VISIBLE); anim = ObjectAnimator.ofFloat(mOptionsLayout, "alpha", 0f, 1.0f); //anim = new TranslateAnimation(0.0f, 0.0f, mOptionsLayout.getHeight(), 0.0f); } //anim.setInterpolator(new AccelerateInterpolator(1.0f)); //anim.setDuration(300); //mOptionsLayout.startAnimation(anim); anim.start(); }
From source file:support.plus.reportit.MainActivity.java
private void createCustomAnimation() { final FloatingActionMenu menu3 = (FloatingActionMenu) findViewById(R.id.menuShare); AnimatorSet set = new AnimatorSet(); ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleX", 1.0f, 0.2f); ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleY", 1.0f, 0.2f); ObjectAnimator scaleInX = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleX", 0.2f, 1.0f); ObjectAnimator scaleInY = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleY", 0.2f, 1.0f); scaleOutX.setDuration(50);// ww w . j a va2 s . c om scaleOutY.setDuration(50); scaleInX.setDuration(150); scaleInY.setDuration(150); scaleInX.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { menu3.getMenuIconView().setImageResource( menu3.isOpened() ? R.drawable.ic_share_white_24dp : R.drawable.ic_done_white_24dp); } }); set.play(scaleOutX).with(scaleOutY); set.play(scaleInX).with(scaleInY).after(scaleOutX); set.setInterpolator(new OvershootInterpolator(2)); menu3.setIconToggleAnimatorSet(set); }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
private void displayPhoto() { // Animate the photo view into its end location. final int[] pos = new int[2]; mBackdrop.getLocationOnScreen(pos);//from w w w.j a v a 2s. c o m LayoutParams layoutParams = new LayoutParams(mSourceBounds.width(), mSourceBounds.height()); mOriginalPos.left = mSourceBounds.left - pos[0]; mOriginalPos.top = mSourceBounds.top - pos[1]; mOriginalPos.right = mOriginalPos.left + mSourceBounds.width(); mOriginalPos.bottom = mOriginalPos.top + mSourceBounds.height(); layoutParams.setMargins(mOriginalPos.left, mOriginalPos.top, mOriginalPos.right, mOriginalPos.bottom); mPhotoStartParams = layoutParams; mPhotoView.setLayoutParams(layoutParams); mPhotoView.requestLayout(); // Load the photo. int photoWidth = getPhotoEndParams().width; if (mPhotoUri != null) { // If we have a URI, the bitmap should be cached directly. ContactPhotoManager.getInstance(this).loadPhoto(mPhotoView, mPhotoUri, photoWidth, false); } else { // Fall back to avatar image. mPhotoView.setImageResource(ContactPhotoManager.getDefaultAvatarResId(this, photoWidth, false)); } mPhotoView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (mAnimationPending) { mAnimationPending = false; PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", mOriginalPos.left, left); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", mOriginalPos.top, top); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", mOriginalPos.right, right); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", mOriginalPos.bottom, bottom); ObjectAnimator anim = ObjectAnimator .ofPropertyValuesHolder(mPhotoView, pvhLeft, pvhTop, pvhRight, pvhBottom) .setDuration(PHOTO_EXPAND_DURATION); if (mAnimationListener != null) { anim.addListener(mAnimationListener); } anim.start(); } } }); attachPhotoHandler(); }
From source file:com.example.piechart3d.PieChart3DView.java
@Override protected void onAttachedToWindow() { // TODO Auto-generated method stub super.onAttachedToWindow(); ObjectAnimator mXAnimator = ObjectAnimator.ofFloat(mRenderer, "angle_x", 0, maxX); mXAnimator.setDuration(2000);/*from ww w .j a v a 2 s . c o m*/ mXAnimator.addListener(new AnimatorListener() { @Override public void onAnimationCancel(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { // progressBar.setProgress(progress); } @Override public void onAnimationRepeat(final Animator animation) { } @Override public void onAnimationStart(final Animator animation) { } }); mXAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { } }); LinearInterpolator di = new LinearInterpolator(); mXAnimator.setInterpolator(di); mXAnimator.start(); }
From source file:com.google.android.apps.santatracker.village.Village.java
private void setIsDay(final boolean isDay, boolean smoothTransition) { ObjectAnimator sunAnim = ObjectAnimator.ofInt(this, "sunOffset", sunOffset, isDay ? 0 : mViewHeight); sunAnim.setInterpolator(new AnticipateOvershootInterpolator()); sunAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); sunAnim.addListener(new Animator.AnimatorListener() { @Override/*from w w w. j av a 2 s .c o m*/ public void onAnimationStart(Animator animation) { if (isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (!isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet dayAnims = new AnimatorSet(); dayAnims.playTogether( // Day values mImageSkyDay.fadeTransition(isDay, smoothTransition), mImageMountainsDay.fadeTransition(isDay, smoothTransition), mPaintMountainsDay.fadeTransition(isDay, smoothTransition)); ObjectAnimator moonAnim = ObjectAnimator.ofInt(this, "moonOffset", moonOffset, isDay ? -mViewHeight : 0); moonAnim.setInterpolator(new AnticipateOvershootInterpolator()); moonAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); moonAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (!isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet nightAnims = new AnimatorSet(); nightAnims.playTogether( // Night values mImageSkyNight.fadeTransition(!isDay, !isDay && smoothTransition), mImageMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition), mPaintMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition)); // When going to the day, delay night animation till after day time has kicked in if (isDay) { nightAnims.setStartDelay(ImageWithAlphaAndSize.ANIM_DURATION); } mFinalAnimations = nightAnims; sunAnim.start(); dayAnims.start(); moonAnim.start(); nightAnims.start(); }
From source file:Main.java
private static void setupChangeAnimationOneTime(final View view) { ObjectAnimator objectAnimator = sMapAnimators.get(view); if (objectAnimator != null) { objectAnimator.cancel();//from w ww. j av a 2 s. c om sMapAnimators.remove(objectAnimator); } OnLayoutChangeListener listener = sMapListeners.get(view); if (listener != null) { view.removeOnLayoutChangeListener(listener); sMapListeners.remove(view); } final OnLayoutChangeListener onLayoutChangeListener = new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { ObjectAnimator objectAnimator = sMapAnimators.get(view); if (objectAnimator != null) { objectAnimator.cancel(); sMapAnimators.remove(objectAnimator); } final ObjectAnimator changeAnimator = getChangeAnimator(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom); sMapAnimators.put(view, changeAnimator); if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) { Animator.AnimatorListener animatorListener = new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (sAnimatorListener != null) { sAnimatorListener.onAnimationStart(animation); } } @Override public void onAnimationRepeat(Animator animation) { if (sAnimatorListener != null) { sAnimatorListener.onAnimationRepeat(animation); } } @Override public void onAnimationEnd(Animator animation) { sMapAnimators.remove(view); if (sAnimatorListener != null) { sAnimatorListener.onAnimationEnd(animation); } } @Override public void onAnimationCancel(Animator animation) { if (sAnimatorListener != null) { sAnimatorListener.onAnimationCancel(animation); } } }; changeAnimator.addListener(animatorListener); changeAnimator.start(); } else { sMapAnimators.remove(view); if (sAnimatorListener != null) { sAnimatorListener.onAnimationEnd(changeAnimator); } } } }; view.addOnLayoutChangeListener(onLayoutChangeListener); sMapListeners.put(view, onLayoutChangeListener); }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
private ObjectAnimator getHideToolbarAnimator(final View view, float fromValue, float toValue) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue); animator.setDuration(cursorToolbarAnimationDuration); animator.setInterpolator(new Expo.EaseIn()); animator.addListener(new AnimatorListenerAdapter() { @Override/*from w ww .j a v a2s .c o m*/ public void onAnimationCancel(Animator animation) { if (view == null) { return; } view.setVisibility(GONE); } @Override public void onAnimationEnd(Animator animation) { if (view == null) { return; } view.setVisibility(GONE); } }); return animator; }