Search in sources :

Example 1 with AnimatorEndListener

use of com.ramotion.paperonboarding.listeners.AnimatorEndListener in project paper-onboarding-android by Ramotion.

the class PaperOnboardingEngine method createBGAnimatorSet.

/**
     * @param color new background color for new
     * @return animator set with background color circular reveal animation
     */
protected AnimatorSet createBGAnimatorSet(final int color) {
    final View bgColorView = new ImageView(mAppContext);
    bgColorView.setLayoutParams(new RelativeLayout.LayoutParams(mRootLayout.getWidth(), mRootLayout.getHeight()));
    bgColorView.setBackgroundColor(color);
    mBackgroundContainer.addView(bgColorView);
    int[] pos = calculateCurrentCenterCoordinatesOfPagerElement(mActiveElementIndex);
    float finalRadius = mRootLayout.getWidth() > mRootLayout.getHeight() ? mRootLayout.getWidth() : mRootLayout.getHeight();
    AnimatorSet bgAnimSet = new AnimatorSet();
    Animator fadeIn = ObjectAnimator.ofFloat(bgColorView, "alpha", 0, 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(bgColorView, pos[0], pos[1], 0, finalRadius);
        circularReveal.setInterpolator(new AccelerateInterpolator());
        bgAnimSet.playTogether(circularReveal, fadeIn);
    } else {
        bgAnimSet.playTogether(fadeIn);
    }
    bgAnimSet.setDuration(ANIM_BACKGROUND_TIME);
    bgAnimSet.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mRootLayout.setBackgroundColor(color);
            bgColorView.setVisibility(View.GONE);
            mBackgroundContainer.removeView(bgColorView);
        }
    });
    return bgAnimSet;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) RelativeLayout(android.widget.RelativeLayout) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with AnimatorEndListener

use of com.ramotion.paperonboarding.listeners.AnimatorEndListener in project paper-onboarding-android by Ramotion.

the class PaperOnboardingEngine method createContentIconShowAnimation.

/**
     * @param currentContentIcon currently displayed view with icon
     * @param newContentIcon     newly created and prepared view to display
     * @return animator set with this animation
     */
protected AnimatorSet createContentIconShowAnimation(final View currentContentIcon, final View newContentIcon) {
    int positionDeltaPx = dpToPixels(CONTENT_ICON_POS_DELTA_Y_DP);
    AnimatorSet animations = new AnimatorSet();
    Animator currentContentMoveUp = ObjectAnimator.ofFloat(currentContentIcon, "y", 0, -positionDeltaPx);
    currentContentMoveUp.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
    currentContentMoveUp.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mContentIconContainer.removeView(currentContentIcon);
        }
    });
    Animator currentContentFadeOut = ObjectAnimator.ofFloat(currentContentIcon, "alpha", 1, 0);
    currentContentFadeOut.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
    animations.playTogether(currentContentMoveUp, currentContentFadeOut);
    Animator newContentMoveUp = ObjectAnimator.ofFloat(newContentIcon, "y", positionDeltaPx, 0);
    newContentMoveUp.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
    Animator newContentFadeIn = ObjectAnimator.ofFloat(newContentIcon, "alpha", 0, 1);
    newContentFadeIn.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
    animations.playTogether(newContentMoveUp, newContentFadeIn);
    animations.setInterpolator(new DecelerateInterpolator());
    return animations;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) AnimatorSet(android.animation.AnimatorSet)

Example 3 with AnimatorEndListener

use of com.ramotion.paperonboarding.listeners.AnimatorEndListener in project paper-onboarding-android by Ramotion.

the class PaperOnboardingEngine method createContentTextShowAnimation.

/**
     * @param currentContentText currently displayed view with text
     * @param newContentText     newly created and prepared view to display
     * @return animator set with this animation
     */
private AnimatorSet createContentTextShowAnimation(final View currentContentText, final View newContentText) {
    int positionDeltaPx = dpToPixels(CONTENT_TEXT_POS_DELTA_Y_DP);
    AnimatorSet animations = new AnimatorSet();
    Animator currentContentMoveUp = ObjectAnimator.ofFloat(currentContentText, "y", 0, -positionDeltaPx);
    currentContentMoveUp.setDuration(ANIM_CONTENT_TEXT_HIDE_TIME);
    currentContentMoveUp.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mContentTextContainer.removeView(currentContentText);
        }
    });
    Animator currentContentFadeOut = ObjectAnimator.ofFloat(currentContentText, "alpha", 1, 0);
    currentContentFadeOut.setDuration(ANIM_CONTENT_TEXT_HIDE_TIME);
    animations.playTogether(currentContentMoveUp, currentContentFadeOut);
    Animator newContentMoveUp = ObjectAnimator.ofFloat(newContentText, "y", positionDeltaPx, 0);
    newContentMoveUp.setDuration(ANIM_CONTENT_TEXT_SHOW_TIME);
    Animator newContentFadeIn = ObjectAnimator.ofFloat(newContentText, "alpha", 0, 1);
    newContentFadeIn.setDuration(ANIM_CONTENT_TEXT_SHOW_TIME);
    animations.playTogether(newContentMoveUp, newContentFadeIn);
    animations.setInterpolator(new DecelerateInterpolator());
    return animations;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) AnimatorSet(android.animation.AnimatorSet)

Aggregations

Animator (android.animation.Animator)3 AnimatorSet (android.animation.AnimatorSet)3 ObjectAnimator (android.animation.ObjectAnimator)3 ValueAnimator (android.animation.ValueAnimator)3 AnimatorEndListener (com.ramotion.paperonboarding.listeners.AnimatorEndListener)3 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)2 View (android.view.View)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1