com.hippo.yorozuya.AnimationUtils Java Examples

The following examples show how to use com.hippo.yorozuya.AnimationUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckTextView.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void createAnimations() {
    float startRadius;
    float endRadius;
    Interpolator interpolator;
    if (mChecked) {
        startRadius = 0;
        endRadius = mMaxRadius;
        interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
    } else {
        startRadius = mMaxRadius;
        endRadius = 0;
        interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
    }
    mRadius = startRadius;

    final ObjectAnimator radiusAnim = ObjectAnimator.ofFloat(this, "radius", startRadius, endRadius);
    radiusAnim.setDuration(ANIMATION_DURATION);
    radiusAnim.setInterpolator(interpolator);
    radiusAnim.addListener(mAnimatorListener);
    radiusAnim.start();
    mAnimator = radiusAnim;
}
 
Example #2
Source File: GalleryActivity.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void hideSlider(View sliderPanel) {
    if (null != mSeekBarPanelAnimator) {
        mSeekBarPanelAnimator.cancel();
        mSeekBarPanelAnimator = null;
    }

    mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
    mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
    mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
    mSeekBarPanelAnimator.addListener(mHideSliderListener);
    mSeekBarPanelAnimator.start();

    if (null != mSystemUiHelper) {
        mSystemUiHelper.hide();
        mShowSystemUi = false;
    }
}
 
Example #3
Source File: GalleryActivity.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void showSlider(View sliderPanel) {
    if (null != mSeekBarPanelAnimator) {
        mSeekBarPanelAnimator.cancel();
        mSeekBarPanelAnimator = null;
    }

    sliderPanel.setTranslationY(sliderPanel.getHeight());
    sliderPanel.setVisibility(View.VISIBLE);

    mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
    mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
    mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
    mSeekBarPanelAnimator.addListener(mShowSliderListener);
    mSeekBarPanelAnimator.start();

    if (null != mSystemUiHelper) {
        mSystemUiHelper.show();
        mShowSystemUi = true;
    }
}
 
Example #4
Source File: GalleryActivity.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private void showSlider(View sliderPanel) {
    if (null != mSeekBarPanelAnimator) {
        mSeekBarPanelAnimator.cancel();
        mSeekBarPanelAnimator = null;
    }

    sliderPanel.setTranslationY(sliderPanel.getHeight());
    sliderPanel.setVisibility(View.VISIBLE);

    mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
    mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
    mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
    mSeekBarPanelAnimator.addListener(mShowSliderListener);
    mSeekBarPanelAnimator.start();

    if (null != mSystemUiHelper) {
        mSystemUiHelper.show();
        mShowSystemUi = true;
    }
}
 
Example #5
Source File: GalleryActivity.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private void hideSlider(View sliderPanel) {
    if (null != mSeekBarPanelAnimator) {
        mSeekBarPanelAnimator.cancel();
        mSeekBarPanelAnimator = null;
    }

    mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
    mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
    mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
    mSeekBarPanelAnimator.addListener(mHideSliderListener);
    mSeekBarPanelAnimator.start();

    if (null != mSystemUiHelper) {
        mSystemUiHelper.hide();
        mShowSystemUi = false;
    }
}
 
Example #6
Source File: CheckTextView.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private void createAnimations() {
    float startRadius;
    float endRadius;
    Interpolator interpolator;
    if (mChecked) {
        startRadius = 0;
        endRadius = mMaxRadius;
        interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
    } else {
        startRadius = mMaxRadius;
        endRadius = 0;
        interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
    }
    mRadius = startRadius;

    final ObjectAnimator radiusAnim = ObjectAnimator.ofFloat(this, "radius", startRadius, endRadius);
    radiusAnim.setDuration(ANIMATION_DURATION);
    radiusAnim.setInterpolator(interpolator);
    radiusAnim.addListener(mAnimatorListener);
    radiusAnim.start();
    mAnimator = radiusAnim;
}
 
Example #7
Source File: Slider.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void startShowBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 1.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 1.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #8
Source File: Slider.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void startHideBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 0.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 0.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #9
Source File: Slider.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void startShowBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 1.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 1.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #10
Source File: GalleryCommentsScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #11
Source File: GalleryListScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void hideActionFab() {
    if (null != mFabLayout && STATE_NORMAL == mState && mShowActionFab) {
        mShowActionFab = false;
        View fab = mFabLayout.getPrimaryFab();
        fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start();
    }
}
 
Example #12
Source File: GalleryListScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void showActionFab() {
    if (null != mFabLayout && STATE_NORMAL == mState && !mShowActionFab) {
        mShowActionFab = true;
        View fab = mFabLayout.getPrimaryFab();
        fab.setVisibility(View.VISIBLE);
        fab.setRotation(-45.0f);
        fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
    }
}
 
Example #13
Source File: Slider.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void startHideBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 0.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 0.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #14
Source File: GalleryListScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void showActionFab() {
    if (null != mFabLayout && STATE_NORMAL == mState && !mShowActionFab) {
        mShowActionFab = true;
        View fab = mFabLayout.getPrimaryFab();
        fab.setVisibility(View.VISIBLE);
        fab.setRotation(-45.0f);
        fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
    }
}
 
Example #15
Source File: Slider.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void startHideBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 0.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 0.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #16
Source File: Slider.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void startShowBubbleAnimation() {
    mBubbleScaleAnimation.cancel();
    mBubbleScaleAnimation.setFloatValues(mDrawBubbleScale, 1.0f);
    mBubbleScaleAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mBubbleScaleAnimation.setDuration((long) (300 * Math.abs(mDrawBubbleScale - 1.0f)));
    mBubbleScaleAnimation.start();
}
 
Example #17
Source File: GalleryCommentsScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #18
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void hideActionFab() {
    if (null != mFabLayout && mShowActionFab) {
        mShowActionFab = false;
        View fab = mFabLayout.getPrimaryFab();
        fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start();
    }
}
 
Example #19
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void showActionFab() {
    if (null != mFabLayout && !mShowActionFab) {
        mShowActionFab = true;
        View fab = mFabLayout.getPrimaryFab();
        fab.setVisibility(View.VISIBLE);
        fab.setRotation(-45.0f);
        fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
    }
}
 
Example #20
Source File: GalleryListScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void hideActionFab() {
    if (null != mFabLayout && STATE_NORMAL == mState && mShowActionFab) {
        mShowActionFab = false;
        View fab = mFabLayout.getPrimaryFab();
        fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener)
                .setDuration(ANIMATE_TIME).setStartDelay(0L)
                .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start();
    }
}
 
Example #21
Source File: GalleryCommentsScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
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()) {
                // Some devices may run this block in non-UI thread.
                // It might be a bug of Android OS.
                // 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();
}
 
Example #22
Source File: GalleryCommentsScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
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()) {
                // Some devices may run this block in non-UI thread.
                // It might be a bug of Android OS.
                // 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();
}