List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:com.truizlop.fabreveallayout.FABRevealLayout.java
private void moveFABToOriginalLocation() { ObjectAnimator fabAnimator = getFABAnimator(); setupAnimationParams(fabAnimator);//from w ww . ja v a 2 s. c o m fabAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); swapViews(); } }); fabAnimator.start(); }
From source file:net.tjohns.badgescanner.ScanActivity.java
public void flipToBack(View view) { // animate the card transition. We do this in 3 steps: // 1. Rotate out the front fragment // 2. Switch the fragments // 3. Rotate in the back if (Build.VERSION.SDK_INT > 11) { ObjectAnimator anim = ObjectAnimator.ofFloat(findViewById(R.id.card_front), ROTATION_AXIS_PROP, 0, 90) .setDuration(ROTATION_HALF_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override/*from w w w . j a va2s . c om*/ public void onAnimationEnd(Animator animation) { findViewById(R.id.card_front).setVisibility(View.GONE); findViewById(R.id.card_back).setVisibility(View.VISIBLE); // rotate in the new note ObjectAnimator.ofFloat(findViewById(R.id.card_back), ROTATION_AXIS_PROP, -90, 0).start(); } }); anim.start(); } else { // Running on Gingerbread, animation class not available findViewById(R.id.card_front).setVisibility(View.GONE); findViewById(R.id.card_back).setVisibility(View.VISIBLE); } }
From source file:net.tjohns.badgescanner.ScanActivity.java
public void flipToFront(View view) { // animate the card transition. We do this in 3 steps: // 1. Rotate out the back fragment // 2. Switch the fragments // 3. Rotate in the front if (Build.VERSION.SDK_INT > 11) { ObjectAnimator anim = ObjectAnimator.ofFloat(findViewById(R.id.card_back), ROTATION_AXIS_PROP, 0, -90) .setDuration(ROTATION_HALF_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override// www . j a v a 2 s . co m public void onAnimationEnd(Animator animation) { findViewById(R.id.card_back).setVisibility(View.GONE); findViewById(R.id.card_front).setVisibility(View.VISIBLE); // rotate in the new note ObjectAnimator.ofFloat(findViewById(R.id.card_front), ROTATION_AXIS_PROP, 90, 0).start(); } }); anim.start(); } else { // Running on Gingerbread, animation class not available findViewById(R.id.card_back).setVisibility(View.GONE); findViewById(R.id.card_front).setVisibility(View.VISIBLE); } }
From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java
@Override public void show() { super.show(); int rootWidth = getRootView().getWidth(); float endFabX; if (getFab().getLeft() > rootWidth / 2f) { endFabX = getFab().getLeft() - getFab().getWidth(); } else {// w ww . j a v a2s . c o m endFabX = getFab().getLeft() + getFab().getWidth(); } PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(View.X, endFabX); PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(View.Y, getFloatingToolbar().getY() * 0.95f); PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getFab(), xProperty, yProperty, scaleXProperty, scaleYProperty); animator.setDuration(FAB_MORPH_DURATION); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(getFloatingToolbar(), "scaleX", 1f); objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION); objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { getFloatingToolbar().setVisibility(View.VISIBLE); getFab().setVisibility(View.INVISIBLE); } }); objectAnimator.start(); }
From source file:android.support.transition.Fade.java
/** * Utility method to handle creating and running the Animator. *//*from w ww . j ava 2s .c o m*/ private Animator createAnimation(final View view, float startAlpha, float endAlpha) { if (startAlpha == endAlpha) { return null; } ViewUtils.setTransitionAlpha(view, startAlpha); final ObjectAnimator anim = ObjectAnimator.ofFloat(view, ViewUtils.TRANSITION_ALPHA, endAlpha); if (DBG) { Log.d(LOG_TAG, "Created animator " + anim); } FadeAnimatorListener listener = new FadeAnimatorListener(view); anim.addListener(listener); addListener(new TransitionListenerAdapter() { @Override public void onTransitionEnd(@NonNull Transition transition) { ViewUtils.setTransitionAlpha(view, 1); ViewUtils.clearNonTransitionAlpha(view); transition.removeListener(this); } }); return anim; }
From source file:org.taurusxi.taurusxicommon.view.drawer.DrawerArrowDrawable.java
public void animateToMain(final Animator.AnimatorListener animatorListener) { ObjectAnimator backAnim = ObjectAnimator.ofFloat(this, "parameter", 1f, 0f); backAnim.setDuration(500);//from w w w.jav a 2 s . c o m backAnim.setInterpolator(LINEAR_INTERPOLATOR); backAnim.addListener(animatorListener); backAnim.start(); }
From source file:com.example.george.sharedelementimplementation.MainActivity.java
public void runExitAnimation() { final long duration = (long) (ANIM_DURATION * MainActivity.sAnimatorScale); ObjectAnimator anim = ObjectAnimator.ofInt(mBackground, "alpha", 0); anim.addListener(new Animator.AnimatorListener() { @Override//from w w w . j a v a 2 s.co m public void onAnimationStart(Animator animation) { // do nothing intended } @Override public void onAnimationEnd(Animator animation) { mIsInFullscreen = false; mIsAnimationPlaying = false; mImage.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { // do nothing intended } @Override public void onAnimationRepeat(Animator animation) { // do nothing intended } }); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(mImage, "translationX", 0, mXDelta), ObjectAnimator.ofFloat(mImage, "translationY", 0, mYDelta), ObjectAnimator.ofFloat(mImage, "scaleX", 1, mImageScale), ObjectAnimator.ofFloat(mImage, "scaleY", 1, mImageScale), // ObjectAnimator.ofFloat(mImage, "alpha", 1, 0), ObjectAnimator.ofFloat(mImage, "imageCrop", 0f, clipRatio), anim); set.setInterpolator(sAccelerator); set.setDuration(duration).start(); mPager.setVisibility(View.GONE); mIsAnimationPlaying = true; }
From source file:io.romain.passport.ui.AddCityActivity.java
private void hideLoadingSpinner() { ObjectAnimator a = ObjectAnimator.ofFloat(mLoading, View.ALPHA, 1, 0); a.addListener(new SimpleAnimatorListener() { @Override/*from ww w .ja v a2s . com*/ public void onAnimationEnd(Animator animation) { mLoading.setVisibility(View.GONE); } }); ObjectAnimator b = ObjectAnimator.ofFloat(mContainer, View.ALPHA, 0, 1); b.addListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { mContainer.setAlpha(0); mContainer.setVisibility(View.VISIBLE); mEditText.requestFocus(); mEditText.setError(getString(R.string.add_city_error)); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); } }); AnimatorSet transition = new AnimatorSet(); transition.playTogether(a, b); transition.setDuration(300); transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)); transition.start(); }
From source file:io.romain.passport.ui.AddCityActivity.java
private void showLoadingSpinner() { View view = getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }/*from w ww . j a v a2 s .c om*/ ObjectAnimator a = ObjectAnimator.ofFloat(mLoading, View.ALPHA, 0, 1); a.addListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { mLoading.setAlpha(0); mLoading.setVisibility(View.VISIBLE); } }); ObjectAnimator b = ObjectAnimator.ofFloat(mContainer, View.ALPHA, 1, 0); b.addListener(new SimpleAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { mContainer.setVisibility(View.INVISIBLE); } }); AnimatorSet transition = new AnimatorSet(); transition.playTogether(a, b); transition.setDuration(300); transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)); transition.start(); }
From source file:com.example.george.sharedelementimplementation.MainActivity.java
public void runEnterAnimation() { final long duration = (long) (ANIM_DURATION * MainActivity.sAnimatorScale); // set starting values for properties we're going to animate. These // values scale and position the full size version down to the thumbnail // size/location, from which we'll animate it back up ObjectAnimator anim = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255); anim.addListener(new Animator.AnimatorListener() { @Override// ww w .ja v a2s . c o m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mIsAnimationPlaying = false; mImage.setVisibility(View.GONE); mPager.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(mImage, "translationX", mXDelta, 0), ObjectAnimator.ofFloat(mImage, "translationY", mYDelta, 0), ObjectAnimator.ofFloat(mImage, "scaleX", mImageScale, 1), ObjectAnimator.ofFloat(mImage, "scaleY", mImageScale, 1), // ObjectAnimator.ofFloat(mImage, "alpha", 0, 1), ObjectAnimator.ofFloat(mImage, "imageCrop", clipRatio, 0f), anim); set.setInterpolator(sDecelerator); set.setDuration(duration).start(); mIsAnimationPlaying = true; }