Search in sources :

Example 41 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project ahbottomnavigation by aurelhubert.

the class AHBottomNavigation method updateNotifications.

/**
	 * Update notifications
	 */
private void updateNotifications(boolean updateStyle, int itemPosition) {
    for (int i = 0; i < views.size(); i++) {
        if (itemPosition != UPDATE_ALL_NOTIFICATIONS && itemPosition != i) {
            continue;
        }
        final AHNotification notificationItem = notifications.get(i);
        final int currentTextColor = AHNotificationHelper.getTextColor(notificationItem, notificationTextColor);
        final int currentBackgroundColor = AHNotificationHelper.getBackgroundColor(notificationItem, notificationBackgroundColor);
        TextView notification = (TextView) views.get(i).findViewById(R.id.bottom_navigation_notification);
        String currentValue = notification.getText().toString();
        boolean animate = !currentValue.equals(String.valueOf(notificationItem.getText()));
        if (updateStyle) {
            notification.setTextColor(currentTextColor);
            if (notificationTypeface != null) {
                notification.setTypeface(notificationTypeface);
            } else {
                notification.setTypeface(null, Typeface.BOLD);
            }
            if (notificationBackgroundDrawable != null) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    Drawable drawable = notificationBackgroundDrawable.getConstantState().newDrawable();
                    notification.setBackground(drawable);
                } else {
                    notification.setBackgroundDrawable(notificationBackgroundDrawable);
                }
            } else if (currentBackgroundColor != 0) {
                Drawable defautlDrawable = ContextCompat.getDrawable(context, R.drawable.notification_background);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    notification.setBackground(AHHelper.getTintDrawable(defautlDrawable, currentBackgroundColor, forceTint));
                } else {
                    notification.setBackgroundDrawable(AHHelper.getTintDrawable(defautlDrawable, currentBackgroundColor, forceTint));
                }
            }
        }
        if (notificationItem.isEmpty() && notification.getText().length() > 0) {
            notification.setText("");
            if (animate) {
                notification.animate().scaleX(0).scaleY(0).alpha(0).setInterpolator(new AccelerateInterpolator()).setDuration(150).start();
            }
        } else if (!notificationItem.isEmpty()) {
            notification.setText(String.valueOf(notificationItem.getText()));
            if (animate) {
                notification.setScaleX(0);
                notification.setScaleY(0);
                notification.animate().scaleX(1).scaleY(1).alpha(1).setInterpolator(new OvershootInterpolator()).setDuration(150).start();
            }
        }
    }
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) AHNotification(com.aurelhubert.ahbottomnavigation.notification.AHNotification) SuppressLint(android.annotation.SuppressLint)

Example 42 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project kickmaterial by byoutline.

the class CategoriesListActivity method launchPostTransitionAnimations.

private void launchPostTransitionAnimations() {
    if (category != null) {
        int color = ContextCompat.getColor(this, category.colorResId);
        binding.categoryCircleIv.setColorFilter(color);
        binding.selectedCategoryIv.setImageResource(category.drawableResId);
        binding.selectCategoryTv.setBackgroundColor(color);
        binding.selectCategoryTv.getBackground().setAlpha(85);
    }
    if (LUtils.hasL()) {
        binding.closeCategoriesIv.setScaleX(0);
        binding.closeCategoriesIv.setScaleY(0);
        ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {

            @Override
            public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                binding.closeCategoriesIv.postDelayed(() -> {
                    // remove listener, we do not want to trigger this animation on exit
                    ActivityCompat.setEnterSharedElementCallback(CategoriesListActivity.this, null);
                    if (isFinishing()) {
                        return;
                    }
                    AnimatorSet closeCategoryAnim = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 0, 1);
                    closeCategoryAnim.setInterpolator(new OvershootInterpolator());
                    closeCategoryAnim.start();
                }, 160);
            }
        });
    }
    binding.categoriesRv.post(() -> binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_from_bottom)));
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorSet(android.animation.AnimatorSet) SharedElementCallback(android.support.v4.app.SharedElementCallback) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 43 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project ENViews by codeestX.

the class ENDownloadView method reset.

public void reset() {
    if (mCurrentState != STATE_RESET) {
        return;
    }
    ValueAnimator resetAnim = ValueAnimator.ofFloat(1.f, 100.f);
    resetAnim.setDuration(500);
    resetAnim.setInterpolator(new OvershootInterpolator());
    resetAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = valueAnimator.getAnimatedFraction();
            invalidate();
        }
    });
    resetAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mFraction = 0;
            mCurrentState = STATE_PRE;
            if (onDownloadStateListener != null) {
                onDownloadStateListener.onResetFinish();
            }
        }
    });
    resetAnim.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 44 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project ENViews by codeestX.

the class ENDownloadView method start.

public void start() {
    if (mCurrentState != STATE_PRE) {
        return;
    }
    mCurrentState = STATE_PRE;
    ValueAnimator preAnim = ValueAnimator.ofFloat(1.f, 100.f);
    preAnim.setDuration(1500);
    preAnim.setInterpolator(new OvershootInterpolator());
    preAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = valueAnimator.getAnimatedFraction();
            invalidate();
        }
    });
    preAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentState = STATE_DOWNLOADING;
            downloadAnim();
        }
    });
    preAnim.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 45 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project InstaMaterial by frogermcs.

the class FeedContextMenuManager method performShowAnimation.

private void performShowAnimation() {
    contextMenuView.setPivotX(contextMenuView.getWidth() / 2);
    contextMenuView.setPivotY(contextMenuView.getHeight());
    contextMenuView.setScaleX(0.1f);
    contextMenuView.setScaleY(0.1f);
    contextMenuView.animate().scaleX(1f).scaleY(1f).setDuration(150).setInterpolator(new OvershootInterpolator()).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            isContextMenuShowing = false;
        }
    });
}
Also used : Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Aggregations

OvershootInterpolator (android.view.animation.OvershootInterpolator)85 ObjectAnimator (android.animation.ObjectAnimator)32 Animator (android.animation.Animator)21 View (android.view.View)21 AnimatorSet (android.animation.AnimatorSet)15 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)14 TextView (android.widget.TextView)14 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)13 Handler (android.os.Handler)12 ValueAnimator (android.animation.ValueAnimator)10 LinearInterpolator (android.view.animation.LinearInterpolator)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)7 LayerDrawable (android.graphics.drawable.LayerDrawable)6 PropertyValuesHolder (android.animation.PropertyValuesHolder)5 Rect (android.graphics.Rect)5 Interpolator (android.view.animation.Interpolator)5 Point (android.graphics.Point)4