Search in sources :

Example 1 with SimpleAnimatorListener

use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.

the class GalleryCommentsScene method hideEditPanelWithAnimation.

private void hideEditPanelWithAnimation() {
    if (null == mFab || null == mEditPanel) {
        return;
    }
    mInAnimation = true;
    int halfW = mEditPanel.getWidth() / 2;
    int halfH = mEditPanel.getHeight() / 2;
    Animator animator = ViewAnimationUtils.createCircularReveal(mEditPanel, halfW, halfH, (float) Math.hypot(halfW, halfH), 0.0f).setDuration(300L);
    animator.addListener(new SimpleAnimatorListener() {

        @Override
        public void onAnimationEnd(Animator a) {
            if (null == mFab || null == mEditPanel) {
                return;
            }
            if (Looper.myLooper() != Looper.getMainLooper()) {
                // Check it here to avoid crash.
                return;
            }
            mEditPanel.setVisibility(View.GONE);
            ((View) mFab).setVisibility(View.VISIBLE);
            int fabStartX = mEditPanel.getLeft() + (mEditPanel.getWidth() / 2) - (mFab.getWidth() / 2);
            int fabStartY = mEditPanel.getTop() + (mEditPanel.getHeight() / 2) - (mFab.getHeight() / 2);
            mFab.setX(fabStartX);
            mFab.setY(fabStartY);
            mFab.setScaleX(0.0f);
            mFab.setScaleY(0.0f);
            mFab.setRotation(-45.0f);
            mFab.animate().translationX(0.0f).translationY(0.0f).scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setInterpolator(AnimationUtils.SLOW_FAST_SLOW_INTERPOLATOR).setDuration(300L).setListener(new SimpleAnimatorListener() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    mInAnimation = false;
                }
            }).start();
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) SimpleAnimatorListener(com.hippo.yorozuya.SimpleAnimatorListener) SuppressLint(android.annotation.SuppressLint)

Example 2 with SimpleAnimatorListener

use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.

the class SearchBar method hideImeAndSuggestionsList.

private void hideImeAndSuggestionsList(boolean animation) {
    // Hide ime
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
    // Hide suggestions list
    if (animation) {
        ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", 0f);
        oa.setDuration(ANIMATE_TIME);
        oa.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
        oa.addListener(new SimpleAnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
                mInAnimation = true;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mListContainer.setVisibility(View.GONE);
                mInAnimation = false;
            }
        });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            oa.setAutoCancel(true);
        }
        oa.start();
    } else {
        setProgress(0f);
        mListContainer.setVisibility(View.GONE);
    }
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) InputMethodManager(android.view.inputmethod.InputMethodManager) SimpleAnimatorListener(com.hippo.yorozuya.SimpleAnimatorListener)

Example 3 with SimpleAnimatorListener

use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.

the class ViewTransition method startAnimations.

private void startAnimations(final View hiddenView, final View shownView) {
    ObjectAnimator oa1 = ObjectAnimator.ofFloat(hiddenView, "alpha", 0f);
    oa1.setDuration(ANIMATE_TIME);
    oa1.addListener(new SimpleAnimatorListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            hiddenView.setVisibility(View.GONE);
            mAnimator1 = null;
        }
    });
    oa1.start();
    mAnimator1 = oa1;
    shownView.setVisibility(View.VISIBLE);
    ObjectAnimator oa2 = ObjectAnimator.ofFloat(shownView, "alpha", 1f);
    oa2.setDuration(ANIMATE_TIME);
    oa2.addListener(new SimpleAnimatorListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimator2 = null;
        }
    });
    oa2.start();
    mAnimator2 = oa2;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SimpleAnimatorListener(com.hippo.yorozuya.SimpleAnimatorListener)

Example 4 with SimpleAnimatorListener

use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.

the class GalleryCommentsScene method showEditPanelWithAnimation.

private void showEditPanelWithAnimation() {
    if (null == mFab || null == mEditPanel) {
        return;
    }
    mInAnimation = true;
    mFab.setTranslationX(0.0f);
    mFab.setTranslationY(0.0f);
    mFab.setScaleX(1.0f);
    mFab.setScaleY(1.0f);
    int fabEndX = mEditPanel.getLeft() + (mEditPanel.getWidth() / 2) - (mFab.getWidth() / 2);
    int fabEndY = mEditPanel.getTop() + (mEditPanel.getHeight() / 2) - (mFab.getHeight() / 2);
    mFab.animate().x(fabEndX).y(fabEndY).scaleX(0.0f).scaleY(0.0f).setInterpolator(AnimationUtils.SLOW_FAST_SLOW_INTERPOLATOR).setDuration(300L).setListener(new SimpleAnimatorListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (null == mFab || null == mEditPanel) {
                return;
            }
            ((View) mFab).setVisibility(View.INVISIBLE);
            mEditPanel.setVisibility(View.VISIBLE);
            int halfW = mEditPanel.getWidth() / 2;
            int halfH = mEditPanel.getHeight() / 2;
            Animator animator = ViewAnimationUtils.createCircularReveal(mEditPanel, halfW, halfH, 0, (float) Math.hypot(halfW, halfH)).setDuration(300L);
            animator.addListener(new SimpleAnimatorListener() {

                @Override
                public void onAnimationEnd(Animator a) {
                    mInAnimation = false;
                }
            });
            animator.start();
        }
    }).start();
}
Also used : Animator(android.animation.Animator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) SimpleAnimatorListener(com.hippo.yorozuya.SimpleAnimatorListener) LinkifyTextView(com.hippo.widget.LinkifyTextView) ImageView(android.widget.ImageView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) SuppressLint(android.annotation.SuppressLint)

Example 5 with SimpleAnimatorListener

use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.

the class FabLayout method setPrimaryFabAnimation.

private void setPrimaryFabAnimation(final View child, final boolean expanded, boolean delay) {
    float startRotation;
    float endRotation;
    float startScale;
    float endScale;
    Interpolator interpolator;
    if (expanded) {
        startRotation = -45.0f;
        endRotation = 0.0f;
        startScale = 0.0f;
        endScale = 1.0f;
        interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
    } else {
        startRotation = 0.0f;
        endRotation = 0.0f;
        startScale = 1.0f;
        endScale = 0.0f;
        interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
    }
    child.setScaleX(startScale);
    child.setScaleY(startScale);
    child.setRotation(startRotation);
    child.animate().scaleX(endScale).scaleY(endScale).rotation(endRotation).setStartDelay(delay ? ANIMATE_TIME : 0L).setDuration(ANIMATE_TIME).setInterpolator(interpolator).setListener(new SimpleAnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (expanded) {
                child.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!expanded) {
                child.setVisibility(View.INVISIBLE);
            }
        }
    }).start();
}
Also used : Animator(android.animation.Animator) Interpolator(android.view.animation.Interpolator) SimpleAnimatorListener(com.hippo.yorozuya.SimpleAnimatorListener)

Aggregations

Animator (android.animation.Animator)9 SimpleAnimatorListener (com.hippo.yorozuya.SimpleAnimatorListener)9 ObjectAnimator (android.animation.ObjectAnimator)3 ValueAnimator (android.animation.ValueAnimator)2 SuppressLint (android.annotation.SuppressLint)2 Interpolator (android.view.animation.Interpolator)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)1 LinkifyTextView (com.hippo.widget.LinkifyTextView)1 ObservedTextView (com.hippo.widget.ObservedTextView)1