Example usage for android.view.animation Animation setAnimationListener

List of usage examples for android.view.animation Animation setAnimationListener

Introduction

In this page you can find the example usage for android.view.animation Animation setAnimationListener.

Prototype

public void setAnimationListener(AnimationListener listener) 

Source Link

Document

Binds an animation listener to this animation.

Usage

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void fadeScaleBubble(final View... views) {
    if (views == null || views.length == 0)
        return;/*from  www.j  av  a 2s .c o m*/
    for (final View v : views) {
        if (v == null || v.getVisibility() != View.VISIBLE)
            continue;
        Animation animation = new AlphaAnimation(1f, 0f);
        animation.setDuration(150);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                v.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        v.startAnimation(animation);
    }

}

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void hideCopyBubble(final Activity context) {
    try {//from w w w .  ja  va2  s  .  c o m
        if (context == null)
            return;
        if (copy == null)
            return;
        final RelativeLayout root = (RelativeLayout) context.findViewById(R.id.main_layout);
        if (copy.getVisibility() == View.VISIBLE) {
            Animation animation = new AlphaAnimation(1f, 0f);
            animation.setDuration(150);
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    root.removeView(copy);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            copy.startAnimation(animation);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.silentcircle.common.util.ViewUtil.java

public static void animateImageChange(final Context context, final ImageView imageView, final int newImage) {
    final Animation animOut = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
    final Animation animIn = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);

    animOut.setAnimationListener(new Animation.AnimationListener() {
        @Override/*from   www .  j  a  v  a2s.  co  m*/
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            imageView.setImageResource(newImage);
            animIn.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                }
            });
            imageView.startAnimation(animIn);
        }
    });
    imageView.startAnimation(animOut);
}

From source file:Main.java

public static void collapse(final View view, final AnimationListener animationListener) {
    if (view == null) {
        return;//w ww  .  j a v a  2  s . c om
    }

    final int initialHeight = view.getMeasuredHeight();

    final Animation animation = new Animation() {
        @Override
        protected void applyTransformation(final float interpolatedTime, final Transformation t) {
            if (interpolatedTime == 1) {
                view.setVisibility(View.GONE);
            } else {
                setHeight(view, initialHeight - (int) (initialHeight * interpolatedTime));
                view.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    animation.setDuration(ANIMATION_DURATION);
    // return animation;
    if (animationListener != null) {
        animation.setAnimationListener(animationListener);
    }
    view.startAnimation(animation);
}

From source file:fm.feed.android.playersdk.fragment.SlidingBottomPlayerFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    if (nextAnim == 0) {
        mOverlay.setVisibility(View.VISIBLE);
        return super.onCreateAnimation(transit, enter, nextAnim);
    }//w w w.  jav a2s .c o  m

    if (!enter) {
        mOverlay.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out));

        return super.onCreateAnimation(transit, enter, nextAnim);
    }

    Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);

    anim.setAnimationListener(new Animation.AnimationListener() {

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            mOverlay.setVisibility(View.VISIBLE);
            mOverlay.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in));
        }
    });
    return anim;
}

From source file:me.oriley.cratesample.fragments.BaseFragment.java

@Override
public Animation onCreateAnimation(int transit, final boolean enter, int nextAnim) {
    if (nextAnim <= 0) {
        return super.onCreateAnimation(transit, enter, nextAnim);
    }/*from  w  w  w.  j av a2  s  .  c o m*/

    final Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            BaseActivity baseActivity = getBaseActivity();
            if (baseActivity != null) {
                baseActivity.onFragmentAnimationComplete();
            }
            anim.setAnimationListener(null);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    return anim;
}

From source file:nl.endran.scrumpoker.fragments.cardselection.CardDisplayFragment.java

public void hide() {
    if (showing) {
        showing = false;/*from ww  w. ja  v a2  s.  c o  m*/
        Animation animation = animationManager.createAnimation(getContext(), R.anim.slide_out_bottom_center);
        animation.setAnimationListener(new SetInVisibleOnAnimationEndListener(cardView));
        cardView.startAnimation(animation);
    }
}

From source file:com.github.vignesh_iopex.confirmdialog.DialogFragment.java

protected void dismissDialogContent() {
    Animation animation = AnimationUtils.loadAnimation(activity, R.anim.slide_to_bottom);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override//from  ww w  .j av  a 2s.c  om
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            dismiss();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    this.dialogContentContainer.startAnimation(animation);
}

From source file:com.pixelpixel.pyp.SplashActivity.java

/** Called when the activity is first created. */
@Override/* ww  w.  j  a  va 2 s .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    //Initializing the application cache
    final int memClass = ((ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    final int cacheSize = 1024 * 1024 * memClass / 4;
    mMemoryCache = new LruCache<String, Object>(cacheSize);

    /*
     * Setting up the animation for the logo
     * */
    final ImageView splash_logo = (ImageView) findViewById(R.id.SplashLogo);
    Animation sa1 = AnimationUtils.loadAnimation(this, R.anim.splash_anim);
    sa1.setAnimationListener(new AnimationListener() {

        public void onAnimationEnd(Animation arg0) {
            /*
             * After the end of the "growing" animation, we call the "shrinking" animation.
             * */
            Animation sa2 = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.splash_anim2);
            sa2.setAnimationListener(new AnimationListener() {

                public void onAnimationEnd(Animation animation) {
                    /*
                     * After the end of the "shrinking" animation, we proceed to the
                     * next screen, the start screen.
                     * */
                    Handler mHandler = new Handler();
                    mHandler.postDelayed(new Runnable() {
                        public void run() {
                            startActivity(new Intent(SplashActivity.this, StartActivity.class));
                            SplashActivity.this.finish();
                        }
                    }, 5000);
                }

                public void onAnimationRepeat(Animation animation) {
                }

                public void onAnimationStart(Animation animation) {
                }

            });
            splash_logo.startAnimation(sa2);
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }

    });

    splash_logo.startAnimation(sa1);
}

From source file:com.webianks.library.ShowHideAnimation.java

public void animateOut(final RelativeLayout view) {
    Animation anim = AnimationUtils.loadAnimation(view.getContext(), R.anim.pop_out);
    anim.setInterpolator(INTERPOLATOR_OUT);
    anim.setDuration(250L);/*  w  w  w  .  j a v  a 2s.  c o m*/
    anim.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationStart(Animation animation) {
            //ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
        }

        public void onAnimationEnd(Animation animation) {
            //ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
            view.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(final Animation animation) {
        }
    });
    view.startAnimation(anim);

}