Search in sources :

Example 81 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Carbon by ZieIony.

the class AnimUtils method flyIn.

public static ValueAnimator flyIn(final View view, Animator.AnimatorListener listener) {
    if (view.getVisibility() != View.VISIBLE)
        ViewHelper.setAlpha(view, 0);
    float start = ViewHelper.getAlpha(view);
    ValueAnimator animator = ValueAnimator.ofFloat(start, 1);
    animator.setDuration((long) (200 * (1 - start)));
    animator.setInterpolator(new DecelerateInterpolator());
    if (listener != null)
        animator.addListener(listener);
    animator.addUpdateListener(valueAnimator -> {
        ViewHelper.setAlpha(view, (Float) valueAnimator.getAnimatedValue());
        ViewHelper.setTranslationY(view, Math.min(view.getHeight() / 2, view.getResources().getDimension(R.dimen.carbon_1dip) * 50.0f) * (1 - (Float) valueAnimator.getAnimatedValue()));
        if (view.getParent() != null)
            ((View) view.getParent()).postInvalidate();
    });
    animator.start();
    return animator;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 82 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Carbon by ZieIony.

the class AnimUtils method popOut.

public static ValueAnimator popOut(final View view, Animator.AnimatorListener listener) {
    float start = ViewHelper.getAlpha(view);
    ValueAnimator animator = ValueAnimator.ofFloat(start, 0);
    animator.setDuration((long) (200 * start));
    animator.setInterpolator(new DecelerateInterpolator());
    if (listener != null)
        animator.addListener(listener);
    animator.addUpdateListener(valueAnimator -> {
        ViewHelper.setAlpha(view, (Float) valueAnimator.getAnimatedValue());
        ViewHelper.setScaleX(view, (Float) valueAnimator.getAnimatedValue());
        ViewHelper.setScaleY(view, (Float) valueAnimator.getAnimatedValue());
        if (view.getParent() != null)
            ((View) view.getParent()).postInvalidate();
    });
    animator.start();
    return animator;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 83 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Carbon by ZieIony.

the class AnimUtils method progressWidthIn.

public static ValueAnimator progressWidthIn(final ProgressBar circularProgress, Animator.AnimatorListener listener) {
    final float arcWidth = circularProgress.getBarPadding() + circularProgress.getBarWidth();
    float start = circularProgress.getBarWidth();
    ValueAnimator animator = ValueAnimator.ofFloat(circularProgress.getBarWidth(), arcWidth);
    animator.setDuration((long) (100 * (arcWidth - start)));
    animator.setInterpolator(new DecelerateInterpolator());
    if (listener != null)
        animator.addListener(listener);
    animator.addUpdateListener(valueAnimator -> {
        float value = (Float) valueAnimator.getAnimatedValue();
        circularProgress.setBarWidth(value);
        circularProgress.setBarPadding(arcWidth - value);
    });
    animator.start();
    return animator;
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 84 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project ImageryHeader by YukiMatsumura.

the class ImageryHeaderFragment method onScrollChanged.

@Override
public void onScrollChanged(int deltaX, int deltaY) {
    final Activity activity = getActivity();
    if (activity == null || activity.isFinishing()) {
        return;
    }
    // Reposition the header bar -- it's normally anchored to the top of the content,
    // but locks to the top of the screen on scroll
    int scrollY = scrollView.getScrollY();
    float newTop = Math.max(headerImageHeightPixels, scrollY + headerBarTopClearance);
    headerBarContainer.setTranslationY(newTop);
    headerBarBackground.setPivotY(headerBarContentsHeightPixels);
    int gapFillDistance = (int) (headerBarTopClearance * GAP_FILL_DISTANCE_MULTIPLIER);
    boolean showGapFill = !showHeaderImage || (scrollY > (headerImageHeightPixels - gapFillDistance));
    float desiredHeaderScaleY = showGapFill ? ((headerBarContentsHeightPixels + gapFillDistance + 1) * 1f / headerBarContentsHeightPixels) : 1f;
    if (!showHeaderImage) {
        headerBarBackground.setScaleY(desiredHeaderScaleY);
    } else if (gapFillShown != showGapFill) {
        headerBarBackground.animate().scaleY(desiredHeaderScaleY).setInterpolator(new DecelerateInterpolator(2f)).setDuration(250).start();
    }
    gapFillShown = showGapFill;
    // Make a shadow. TODO: Do not need if running on AndroidL
    headerBarShadow.setVisibility(View.VISIBLE);
    if (headerBarTopClearance != 0) {
        // Fill the gap between status bar and header bar with color
        float gapFillProgress = Math.min(Math.max(getProgress(scrollY, headerImageHeightPixels - headerBarTopClearance * 2, headerImageHeightPixels - headerBarTopClearance), 0), 1);
        // TODO: Set elevation properties if running on AndroidL
        headerBarShadow.setAlpha(gapFillProgress);
    }
    // Move background image (parallax effect)
    headerImageContainer.setTranslationY(scrollY * HEADER_IMAGE_BACKGROUND_PARALLAX_EFFECT_MULTIPLIER);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Activity(android.app.Activity)

Example 85 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Carbon by ZieIony.

the class BottomBar method deselectItem.

private void deselectItem(final View item) {
    final ImageView icon = (ImageView) item.findViewById(R.id.carbon_bottomIcon);
    icon.setSelected(false);
    final TextView text = (TextView) item.findViewById(R.id.carbon_bottomText);
    text.setSelected(false);
    ValueAnimator animator = ValueAnimator.ofFloat(getResources().getDimension(R.dimen.carbon_bottomBarActiveTextSize) / getResources().getDimension(R.dimen.carbon_bottomBarInactiveTextSize), 1);
    animator.setDuration(200);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            text.setScaleX((Float) animation.getAnimatedValue());
            text.setScaleY((Float) animation.getAnimatedValue());
            text.postInvalidate();
        }
    });
    animator.start();
    ValueAnimator animator2 = ValueAnimator.ofFloat(-getResources().getDimension(R.dimen.carbon_1dip) * 2, 0);
    animator2.setDuration(200);
    animator2.setInterpolator(new DecelerateInterpolator());
    animator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            icon.setTranslationY((Float) animation.getAnimatedValue());
            icon.postInvalidate();
        }
    });
    animator2.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Aggregations

DecelerateInterpolator (android.view.animation.DecelerateInterpolator)312 ObjectAnimator (android.animation.ObjectAnimator)80 Animator (android.animation.Animator)66 ValueAnimator (android.animation.ValueAnimator)59 View (android.view.View)58 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)55 AnimatorSet (android.animation.AnimatorSet)52 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 ImageView (android.widget.ImageView)32 AlphaAnimation (android.view.animation.AlphaAnimation)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)29 Animation (android.view.animation.Animation)21 TextView (android.widget.TextView)20 Point (android.graphics.Point)18 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)18 Paint (android.graphics.Paint)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 ScaleAnimation (android.view.animation.ScaleAnimation)14 AnimatorSet (com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet)14 ObjectAnimator (com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator)14