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.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java

public static void doAction(View view, int duration, float scaleX, float scaleY) {
    try {//from  www. ja  va2s  . c o  m
        if (view.getScaleX() == 1) {
            ViewCompat.animate(view).setDuration(duration).scaleX(scaleX).scaleY(scaleY)
                    .setInterpolator(new CycleInterpolator(0.5f))
                    .setListener(new ViewPropertyAnimatorListener() {

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

                        @Override
                        public void onAnimationEnd(final View v) {
                        }

                        @Override
                        public void onAnimationCancel(final View view) {
                        }
                    }).withLayer().start();
        }
    } catch (Exception e) {
        Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction");
    }
}

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

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

                    public void onAnimationCancel(View view) {
                    }

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

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

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

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticAction.java

public static void doAction(ViewGroup view, int duration, float scaleX, float scaleY) {
    try {/*from   w  w w  .java  2 s  .  com*/
        if (view.getScaleX() == 1) {
            ViewCompat.animate(view).setDuration(duration).scaleX(scaleX).scaleY(scaleY)
                    .setInterpolator(new CycleInterpolator(0.5f))
                    .setListener(new ViewPropertyAnimatorListener() {

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

                        @Override
                        public void onAnimationEnd(final View v) {
                        }

                        @Override
                        public void onAnimationCancel(final View view) {
                        }
                    }).withLayer().start();

            for (int index = 0; index < ((ViewGroup) view).getChildCount(); ++index) {
                View nextChild = ((ViewGroup) view).getChildAt(index);
                ViewCompat.animate(nextChild).setDuration(duration).scaleX(scaleX).scaleY(scaleY)
                        .setInterpolator(new CycleInterpolator(0.5f))
                        .setListener(new ViewPropertyAnimatorListener() {

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

                            @Override
                            public void onAnimationEnd(final View v) {
                            }

                            @Override
                            public void onAnimationCancel(final View view) {
                            }
                        }).withLayer().start();
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "only ViewGroups : likes RelativeLayout, LinearLayout, etc could doAction");
    }
}

From source file:jp.wasabeef.recyclerview.animators.change.TinyScaleAnimate.java

public void animateChange(final RecyclerView.ViewHolder oldHolder, final RecyclerView.ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    final long duration = (long) (0.5f * mDispatcher.getChangeDuration());

    if (oldHolder.itemView != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(oldHolder.itemView);
        oldViewAnim.translationX(toX - fromX);
        oldViewAnim.translationY(toY - fromY);

        oldViewAnim.setDuration(duration);
        oldViewAnim.scaleX(SCALE_VALUE).scaleY(SCALE_VALUE);
        oldViewAnim.setListener(new ViewPropertyAnimatorListener() {
            @Override//  w  ww.  j ava 2s .co m
            public void onAnimationStart(View view) {
                mDispatcher.dispatchChangeStarting(oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                mDispatcher.dispatchChangeFinished(oldHolder, true);

                if (newHolder.itemView != null) {
                    ViewCompat.setScaleX(newHolder.itemView, SCALE_VALUE);
                    ViewCompat.setScaleY(newHolder.itemView, SCALE_VALUE);
                    ViewCompat.setAlpha(newHolder.itemView, 1.f);
                    final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newHolder.itemView);
                    newViewAnimation.translationX(0).translationY(0);
                    newViewAnimation.scaleX(1.f).scaleY(1.f);
                    newViewAnimation.setDuration(duration);
                    newViewAnimation.setListener(new ViewPropertyAnimatorListener() {
                        @Override
                        public void onAnimationStart(View view) {
                            mDispatcher.dispatchChangeStarting(newHolder, false);
                        }

                        @Override
                        public void onAnimationEnd(View view) {
                            newViewAnimation.setListener(null);
                            ViewCompat.setAlpha(view, 1);
                            ViewCompat.setTranslationX(view, 0);
                            ViewCompat.setTranslationY(view, 0);
                            mDispatcher.dispatchChangeFinished(newHolder, false);
                        }

                        @Override
                        public void onAnimationCancel(View view) {
                            ViewHelper.clear(view);
                        }
                    }).start();
                }
            }

            @Override
            public void onAnimationCancel(View view) {
                ViewHelper.clear(view);
            }
        }).start();
    }

}

From source file:com.uele.examples.splashscreenmvp.ui.view.behavior.FabBehavior.java

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

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

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

From source file:com.dmcc.bid.util.AnimatorUtil.java

/**
 * ??//w ww  .  j  a  va  2  s .  c o m
 * <p/>
 * ?view?
 * ?
 *
 * @param root
 */
public static void addGlobaLayoutListener(final View root, final View childView) {
    root.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

            Rect rect = new Rect();
            // ?root?
            root.getWindowVisibleDisplayFrame(rect);
            // ?root??(View?)
            int rootInvisibleHeight = root.getRootView().getHeight() - rect.bottom;
            // ??100
            if (rootInvisibleHeight > 100) {
                //                            Logger.e("?");
                int[] location = new int[2];
                AnimatorUtil.scaleHide(childView, new ViewPropertyAnimatorListener() {
                    @Override
                    public void onAnimationStart(View view) {
                        childView.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationEnd(View view) {

                    }

                    @Override
                    public void onAnimationCancel(View view) {

                    }
                });
            } else {
                // ??
                //                            Logger.e("");
                AnimatorUtil.scaleShow(childView, new ViewPropertyAnimatorListener() {
                    @Override
                    public void onAnimationStart(View view) {

                    }

                    @Override
                    public void onAnimationEnd(View view) {

                        childView.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationCancel(View view) {

                    }
                });
            }
        }
    });
}

From source file:jp.wasabeef.recyclerview.animators.AnimateChange.java

public void animateChange(final RecyclerView.ViewHolder oldHolder, final RecyclerView.ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    final View view = oldHolder.itemView;
    final View newView = newHolder.itemView;
    long oldAnimDuration = (long) (0.5f * mDispatcher.getChangeDuration());
    long newAnimDuration = mDispatcher.getChangeDuration();

    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view);
        oldViewAnim.translationX(toX - fromX);
        oldViewAnim.translationY(toY - fromY);

        oldViewAnim.setDuration(oldAnimDuration);
        oldViewAnim.alpha(0).setListener(new ViewPropertyAnimatorListener() {
            @Override//w w w.  ja va  2s  .c o m
            public void onAnimationStart(View view) {
                mDispatcher.dispatchChangeStarting(oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                mDispatcher.dispatchChangeFinished(oldHolder, true);
            }

            @Override
            public void onAnimationCancel(View view) {
                ViewHelper.clear(view);
            }
        }).start();
    }

    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        newViewAnimation.translationX(0).translationY(0);

        newViewAnimation.setDuration(newAnimDuration);
        newViewAnimation.alpha(1).setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
                mDispatcher.dispatchChangeStarting(newHolder, false);
            }

            @Override
            public void onAnimationEnd(View view) {
                newViewAnimation.setListener(null);
                ViewCompat.setAlpha(newView, 1);
                ViewCompat.setTranslationX(newView, 0);
                ViewCompat.setTranslationY(newView, 0);
                mDispatcher.dispatchChangeFinished(newHolder, false);
            }

            @Override
            public void onAnimationCancel(View view) {
                ViewHelper.clear(view);
            }
        }).start();
    }
}

From source file:com.geecko.QuickLyric.utils.RefreshButtonBehavior.java

public void animateOut(final FloatingActionButton button) {
    int translationY = button.getHeight()
            + ((CoordinatorLayout.LayoutParams) button.getLayoutParams()).bottomMargin;
    ViewCompat.animate(button).translationY(translationY).setInterpolator(INTERPOLATOR).withLayer()
            .setListener(new ViewPropertyAnimatorListener() {
                public void onAnimationStart(View view) {
                    RefreshButtonBehavior.this.mIsAnimatingOut = true;
                }//  w w  w .  ja  va2 s .c o  m

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

                public void onAnimationEnd(View view) {
                    RefreshButtonBehavior.this.mIsAnimatingOut = false;
                    view.setVisibility(View.INVISIBLE);
                    visible = false;
                }
            }).start();
}

From source file:com.evandroid.musica.utils.RefreshButtonBehavior.java

public void animateOut(final FloatingActionButton button) {
    int translationY = button.getHeight()
            + ((CoordinatorLayout.LayoutParams) button.getLayoutParams()).bottomMargin;
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(translationY).setInterpolator(INTERPOLATOR).withLayer()
                .setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        RefreshButtonBehavior.this.mIsAnimatingOut = true;
                    }//from  w  w w  .  j  a  v  a2 s . c  o  m

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

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

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

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

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_complete, container, false);
    ButterKnife.bind(this, view);
    mCompleteButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w w w.  j a  v a  2s.  co  m*/
        public void onClick(View v) {
            AnimUtils.animteViewsOut(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {

                }

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

                @Override
                public void onAnimationCancel(View view) {

                }
            }, mCompleteImage, mCompleteTitle, mCompleteContent, mCompleteButton);
        }
    });
    return view;
}