Example usage for android.support.v4.view ViewPropertyAnimatorListener ViewPropertyAnimatorListener

List of usage examples for android.support.v4.view ViewPropertyAnimatorListener ViewPropertyAnimatorListener

Introduction

In this page you can find the example usage for android.support.v4.view ViewPropertyAnimatorListener ViewPropertyAnimatorListener.

Prototype

ViewPropertyAnimatorListener

Source Link

Usage

From source file:com.events.events.features.welcome.WelcomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_welcome, container, false);
    ButterKnife.bind(this, view);

    mGetStartedButton.setAlpha(0f);/* w w w.j a  v  a  2 s .co m*/
    mWelcomeImage.setAlpha(0f);
    mCompleteTitle.setAlpha(0f);
    mCompleteContent.setAlpha(0f);

    mGetStartedButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            animateOut(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {

                }

                @Override
                public void onAnimationEnd(View view) {
                    ((WelcomeActivity) getActivity()).nextSlide();
                }

                @Override
                public void onAnimationCancel(View view) {

                }
            });
        }
    });

    return view;
}

From source file:eu.power_switch.gui.animation.ScrollAwareFABBehavior.java

/**
 * Same animation that FloatingActionButton.Behavior uses to
 * hide the FAB when the AppBarLayout exits
 *
 * @param floatingActionButton FAB//from w w  w .j  a va 2s . c om
 */
private void animateOut(final FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }

    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(0.0F).scaleY(0.0F).alpha(0.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(),
                android.R.anim.fade_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

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

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

From source file:com.events.events.features.launch.LaunchActivity.java

@Override
public void showWelcomeActivity() {
    AnimUtils.animteViewsOut(new ViewPropertyAnimatorListener() {
        @Override//  w w w .  j a  va2 s .  co  m
        public void onAnimationStart(View view) {

        }

        @Override
        public void onAnimationEnd(View view) {
            ActivityUtils.with(LaunchActivity.this).startWelcomeActivity();
            finish();
        }

        @Override
        public void onAnimationCancel(View view) {

        }
    }, mAppLogo, mProgress);
}

From source file:net.nym.napply.library.behavior.BottomScrollShowHideBehavior.java

private void show(final View child) {
    if (child == null) {
        return;/*  w w w . j  a  v  a2 s  . c om*/
    }
    final float translationY = child.getTranslationY();
    //hide -> show
    if (translationY <= 0 || isAnimate) {
        return;
    }
    ViewPropertyAnimatorCompat animator = ViewCompat.animate(child);
    animator.translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {
                    child.setVisibility(View.VISIBLE);
                    isAnimate = true;
                }

                @Override
                public void onAnimationEnd(View view) {
                    isAnimate = false;
                }

                @Override
                public void onAnimationCancel(View view) {
                    hide(child);
                }
            }).start();
}

From source file:com.brookmanholmes.bma.utils.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    // changed from original to do a translation and removed support for lower APIs since it's
    // not needed in my app
    ViewCompat.animate(button).translationY(button.getHeight()).setInterpolator(INTERPOLATOR).withLayer()
            .setListener(new ViewPropertyAnimatorListener() {
                public void onAnimationStart(View view) {
                    ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                }// ww w.j a  v a2s .co  m

                public void onAnimationCancel(View view) {
                    ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                }

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

}

From source file:com.iven.lfflfeedreader.mainact.fabscroll.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        fabscroll.this.mIsAnimatingOut = true;
                    }//from   w  w w .  j  a  va 2 s  .c om

                    public void onAnimationCancel(View view) {
                        fabscroll.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        fabscroll.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                fabscroll.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                fabscroll.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java

private void show(final View child) {
    if (child == null) {
        return;/*w  w w. jav  a2  s .  co m*/
    }
    final float translationY = child.getTranslationY();
    //hide -> show
    if (translationY >= 0 || isAnimate) {
        return;
    }
    ViewPropertyAnimatorCompat animator = ViewCompat.animate(child);
    animator.translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {
                    child.setVisibility(View.VISIBLE);
                    isAnimate = true;
                }

                @Override
                public void onAnimationEnd(View view) {
                    isAnimate = false;
                }

                @Override
                public void onAnimationCancel(View view) {
                    hide(child);
                }
            }).start();
}

From source file:com.lamcreations.scaffold.common.views.behaviors.FabBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        FabBehavior.this.mIsAnimatingOut = true;
                    }/* w w  w  . j  a  v  a  2 s .  co  m*/

                    public void onAnimationCancel(View view) {
                        FabBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        FabBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.scaffold_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                FabBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                FabBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:im.ene.ribbon.AnimUtil.java

static void animate(BottomNavigationView parent, View view, final View backgroundOverlay,
        final ColorDrawable backgroundDrawable, final int newColor, long duration) {
    int centerX = (int) (ViewCompat.getX(view) + (view.getWidth() / 2));
    int centerY = parent.getPaddingTop() + view.getHeight() / 2;

    backgroundOverlay.clearAnimation();//w w  w . j a va  2s  . co m

    final Object animator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator);
        if (currentAnimator != null) {
            //currentAnimator.end();
            currentAnimator.cancel();
        }

        final float startRadius = 1;
        final float finalRadius = centerX > parent.getWidth() / 2 ? centerX : parent.getWidth() - centerX;
        animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius,
                finalRadius);
        backgroundOverlay.setTag(R.id.ribbon_background_overlay_animator, animator);
    } else {
        ViewCompat.setAlpha(backgroundOverlay, 0);
        animator = ViewCompat.animate(backgroundOverlay).alpha(1);
    }

    backgroundOverlay.setBackgroundColor(newColor);
    backgroundOverlay.setVisibility(View.VISIBLE);

    if (animator instanceof ViewPropertyAnimatorCompat) {
        ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final View view) {
            }

            @Override
            public void onAnimationEnd(final View view) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final View view) {
                cancelled = true;
            }
        }).setDuration(duration).start();
    } else {
        Animator animator1 = (Animator) animator;
        animator1.setDuration(duration);
        animator1.setInterpolator(new DecelerateInterpolator());
        animator1.addListener(new Animator.AnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final Animator animation) {
            }

            @Override
            public void onAnimationEnd(final Animator animation) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final Animator animation) {
                cancelled = true;
            }

            @Override
            public void onAnimationRepeat(final Animator animation) {
            }
        });

        animator1.start();
    }
}

From source file:com.bluros.music.utils.FabAnimationUtils.java

public static void scaleOut(final View fab, long duration, final ScaleCallback callback) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.animate(fab).scaleX(0.0F).scaleY(0.0F).alpha(0.0F)
                .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR).setDuration(duration).withLayer()
                .setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        if (callback != null)
                            callback.onAnimationStart();
                    }//from  w  w w .  j  a  v  a  2s . c  o m

                    public void onAnimationCancel(View view) {
                    }

                    public void onAnimationEnd(View view) {
                        view.setVisibility(View.INVISIBLE);
                        if (callback != null)
                            callback.onAnimationEnd();
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(fab.getContext(), R.anim.design_fab_out);
        anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(duration);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                if (callback != null)
                    callback.onAnimationStart();
            }

            public void onAnimationEnd(Animation animation) {
                fab.setVisibility(View.INVISIBLE);
                if (callback != null)
                    callback.onAnimationEnd();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //
            }
        });
        fab.startAnimation(anim);
    }
}