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.example.xyzreader.util.ScrollAwareFABBehavior.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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//from  w  ww . j  a  v a2 s.  com

                    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(button.getContext(),
                android.support.design.R.anim.design_fab_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;
                button.setVisibility(View.GONE);
            }

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

From source file:cn.lingox.android.share.view.ScrollAwareFABBehavior.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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//  w ww.  j  a v  a 2s .com

                    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(button.getContext(),
                android.support.design.R.anim.design_fab_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;
                button.setVisibility(View.GONE);
            }

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

From source file:com.fangzp.daily.widget.ScrollAwareFABBehavior.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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//from w w w.  jav a 2 s  .c  om

                    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(button.getContext(), R.anim.design_fab_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;
                button.setVisibility(View.GONE);
            }

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

From source file:com.simon.dribbble.widget.navigationbar.behavior.BehaviorScrollZoomFab.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) {
                        BehaviorScrollZoomFab.this.mIsAnimatingOut = true;
                    }/*from ww  w. java2  s  . co m*/

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

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

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

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

From source file:vc908.stickerfactory.ui.advancedrecyclerview.draggable.BaseDraggableItemDecorator.java

protected void moveToDefaultPosition(View targetView, boolean animate) {
    final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView));
    final int halfItemHeight = targetView.getHeight() / 2;
    final float translationProportion = (halfItemHeight > 0)
            ? Math.abs((float) curTranslationY / halfItemHeight)
            : 0;/*from www .ja v a 2s  .c om*/
    final float t = 1.0f - Math.min(translationProportion, 1.0f);
    final int animDuration = (int) (mReturnToDefaultPositionDuration * (1.0f - (t * t)) + 0.5f);

    if (supportsViewPropertyAnimation() && animate
            && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)
            && (Math.abs(curTranslationY) > mReturnToDefaultPositionAnimateThreshold)) {
        final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationY(0.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                animator.setListener(null);
                ViewCompat.setTranslationY(view, 0);

                // invalidate explicitly to refresh other decorations
                if (view.getParent() instanceof RecyclerView) {
                    ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        });
        animator.start();
    } else {
        ViewCompat.setTranslationY(targetView, 0);
    }
}

From source file:it.bellotti.android.materialdesignsample.ui.widget.ScrollAwareFABBehavior.java

private void animateFabOut(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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//from   w w w.j  ava 2s  .c  o  m

                    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 = new ScaleAnimation(1.0F, 1.0F, 0.0F, 0.0F);
        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;
                button.setVisibility(View.GONE);
            }

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

From source file:com.android.purenexussettings.utils.FabScrollAnimator.java

private void animateOut(final FloatingActionButton button) {
    ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR).withLayer()
            .setListener(new ViewPropertyAnimatorListener() {
                public void onAnimationStart(View view) {
                    FabScrollAnimator.this.mIsAnimatingOut = true;
                }/*  w  ww . jav a2s.c om*/

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

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

From source file:com.megaphone.skoozi.FloatingActionButtonScrollBehavior.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) {
                        FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true;
                    }/*  www.  j av a 2s  . c o  m*/

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

                    public void onAnimationEnd(View view) {
                        FloatingActionButtonScrollBehavior.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) {
                FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true;
            }

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

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

From source file:com.megaphone.skoozi.FloatingActionButtonScrollMorphBehavior.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) {
                        FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true;
                    }// w ww. j  a  v  a2s.  co  m

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

                    public void onAnimationEnd(View view) {
                        FloatingActionButtonScrollMorphBehavior.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) {
                FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true;
            }

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

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

From source file:com.ua.max.oliynick.flicker.widgets.ScrollAwareFABBehavior.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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//  ww w .  j a v  a 2s.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();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_disappear);
        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;
                button.setVisibility(View.GONE);
            }

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