Search in sources :

Example 6 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project animate by hitherejoe.

the class ForegroundFrame method addContentView.

private void addContentView(FrameLayout container) {
    inflate(getContext(), R.layout.layout_frame, this);
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_quiz);
    floatingActionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ViewPropertyAnimatorCompat animatorCompat = buildAnimation(v);
            animatorCompat.setListener(new ViewPropertyAnimatorListener() {

                @Override
                public void onAnimationStart(View view) {
                }

                @Override
                public void onAnimationEnd(View view) {
                    doStuff();
                }

                @Override
                public void onAnimationCancel(View view) {
                }
            });
        }
    });
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) View(android.view.View)

Example 7 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project BottomNavigation by Ashok-Varma.

the class BadgeItem method hide.

/**
     * @param animate whether to animate the change
     * @return this, to allow builder pattern
     */
public BadgeItem hide(boolean animate) {
    mIsHidden = true;
    if (isWeakReferenceValid()) {
        TextView textView = mTextViewRef.get();
        if (animate) {
            ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
            animatorCompat.cancel();
            animatorCompat.setDuration(mAnimationDuration);
            animatorCompat.scaleX(0).scaleY(0);
            animatorCompat.setListener(new ViewPropertyAnimatorListener() {

                @Override
                public void onAnimationStart(View view) {
                // Empty body
                }

                @Override
                public void onAnimationEnd(View view) {
                    view.setVisibility(View.GONE);
                }

                @Override
                public void onAnimationCancel(View view) {
                    view.setVisibility(View.GONE);
                }
            });
            animatorCompat.start();
        } else {
            textView.setVisibility(View.GONE);
        }
    }
    return this;
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) TextView(android.widget.TextView) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) TextView(android.widget.TextView) View(android.view.View)

Example 8 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project android-advancedrecyclerview by h6ah4i.

the class BaseDraggableItemDecorator method moveToDefaultPosition.

protected void moveToDefaultPosition(View targetView, float initialScale, float initialRotation, float initialAlpha, boolean animate) {
    final float initialTranslationZ = ViewCompat.getTranslationZ(targetView);
    final float durationFactor = determineMoveToDefaultPositionAnimationDurationFactor(targetView, initialScale, initialRotation, initialAlpha);
    final int animDuration = (int) (mReturnToDefaultPositionDuration * durationFactor);
    if (supportsViewPropertyAnimation() && animate && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)) {
        ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        ViewCompat.setScaleX(targetView, initialScale);
        ViewCompat.setScaleY(targetView, initialScale);
        ViewCompat.setRotation(targetView, initialRotation);
        ViewCompat.setAlpha(targetView, initialAlpha);
        // to render on top of other items
        ViewCompat.setTranslationZ(targetView, initialTranslationZ + 1);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationX(0.0f);
        animator.translationY(0.0f);
        animator.translationZ(initialTranslationZ);
        animator.alpha(1.0f);
        animator.rotation(0);
        animator.scaleX(1.0f);
        animator.scaleY(1.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
                animator.setListener(null);
                resetDraggingItemViewEffects(view, initialTranslationZ);
                // 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 {
        resetDraggingItemViewEffects(targetView, initialTranslationZ);
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 9 with ViewPropertyAnimatorListener

use of android.support.v4.view.ViewPropertyAnimatorListener in project ToolBarLib by jjhesk.

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)) {
                    //execute Parent MEthod
                    view.setDrawingCacheEnabled(true);
                }
            }

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

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

Example 10 with ViewPropertyAnimatorListener

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

the class FragmentComments method showLayoutActions.

private void showLayoutActions() {
    for (int index = layoutActions.getChildCount() - 1; index >= 0; index--) {
        final View view = layoutActions.getChildAt(index);
        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) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

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