Search in sources :

Example 1 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project Meizhi by drakeet.

the class ScrollAwareFABBehavior method animateOut.

// Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits
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;
            }

            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);
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) Animation(android.view.animation.Animation) View(android.view.View)

Example 2 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project MaterialSearchView by MiguelCatalan.

the class AnimationUtil method fadeInView.

public static void fadeInView(View view, int duration, final AnimationListener listener) {
    view.setVisibility(View.VISIBLE);
    view.setAlpha(0f);
    ViewPropertyAnimatorListener vpListener = null;
    if (listener != null) {
        vpListener = new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
                if (!listener.onAnimationStart(view)) {
                    view.setDrawingCacheEnabled(true);
                }
            }

            @Override
            public void onAnimationEnd(View view) {
                if (!listener.onAnimationEnd(view)) {
                    view.setDrawingCacheEnabled(false);
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        };
    }
    ViewCompat.animate(view).alpha(1f).setDuration(duration).setListener(vpListener);
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) View(android.view.View)

Example 3 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project Reader by TheKeeperOfPie.

the class FragmentThreadList method hideLayoutActions.

private void hideLayoutActions(long offset) {
    for (int index = 0; index < layoutActions.getChildCount(); index++) {
        final View view = layoutActions.getChildAt(index);
        view.setScaleX(1f);
        view.setScaleY(1f);
        view.setAlpha(1f);
        final int finalIndex = index;
        ViewCompat.animate(view).alpha(0f).scaleX(0f).scaleY(0f).setInterpolator(fastOutSlowInInterpolator).setDuration(DURATION_ACTIONS_FADE).setStartDelay((long) (index * offset * OFFSET_MODIFIER)).setListener(new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                view.setVisibility(View.GONE);
                if (finalIndex == layoutActions.getChildCount() - 1) {
                    buttonExpandActions.setImageResource(R.drawable.ic_unfold_more_white_24dp);
                    buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        }).start();
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 4 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project Reader by TheKeeperOfPie.

the class FragmentThreadList method showLayoutActions.

private void showLayoutActions() {
    for (int index = layoutActions.getChildCount() - 1; index >= 0; index--) {
        final View view = layoutActions.getChildAt(index);
        view.setScaleX(0f);
        view.setScaleY(0f);
        view.setAlpha(0f);
        view.setVisibility(View.VISIBLE);
        final int finalIndex = index;
        ViewCompat.animate(view).alpha(1f).scaleX(1f).scaleY(1f).setInterpolator(fastOutSlowInInterpolator).setDuration(DURATION_ACTIONS_FADE).setStartDelay((long) ((layoutActions.getChildCount() - 1 - index) * DURATION_ACTIONS_FADE * OFFSET_MODIFIER)).setListener(new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
                if (finalIndex == 0) {
                    buttonExpandActions.setImageResource(android.R.color.transparent);
                }
            }

            @Override
            public void onAnimationEnd(View view) {
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        }).start();
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 5 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project Reader by TheKeeperOfPie.

the class FragmentComments method hideLayoutActions.

private void hideLayoutActions(long offset) {
    for (int index = 0; index < layoutActions.getChildCount(); index++) {
        final View view = layoutActions.getChildAt(index);
        view.setScaleX(1f);
        view.setScaleY(1f);
        view.setAlpha(1f);
        final int finalIndex = index;
        ViewCompat.animate(view).alpha(0f).scaleX(0f).scaleY(0f).setInterpolator(fastOutSlowInInterpolator).setDuration(DURATION_ACTIONS_FADE).setStartDelay((long) (index * offset * OFFSET_MODIFIER)).setListener(new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                view.setVisibility(View.GONE);
                if (finalIndex == layoutActions.getChildCount() - 1) {
                    buttonExpandActions.setImageResource(R.drawable.ic_unfold_more_white_24dp);
                    buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        }).start();
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

ViewPropertyAnimatorListener (android.support.v4.view.ViewPropertyAnimatorListener)13 View (android.view.View)13 RecyclerView (android.support.v7.widget.RecyclerView)5 TextView (android.widget.TextView)4 BindView (butterknife.BindView)4 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)3 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 Animation (android.view.animation.Animation)1 AbsListView (android.widget.AbsListView)1 ListView (android.widget.ListView)1