Search in sources :

Example 11 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project AdvancedMaterialDrawer by madcyph3r.

the class MaterialRippleLayout method startRipple.

@TargetApi(14)
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled)
        return;
    float endRadius = getEndRadius();
    cancelAnimations();
    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });
    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty(), radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty(), rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);
    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) TargetApi(android.annotation.TargetApi)

Example 12 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project material by rey5137.

the class BottomSheetDialog method applyStyle.

public BottomSheetDialog applyStyle(int styleId) {
    Context context = getContext();
    TypedArray a = context.obtainStyledAttributes(styleId, R.styleable.BottomSheetDialog);
    for (int i = 0, count = a.getIndexCount(); i < count; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.BottomSheetDialog_android_layout_height)
            heightParam(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if (attr == R.styleable.BottomSheetDialog_bsd_cancelable)
            cancelable(a.getBoolean(attr, true));
        else if (attr == R.styleable.BottomSheetDialog_bsd_canceledOnTouchOutside)
            canceledOnTouchOutside(a.getBoolean(attr, true));
        else if (attr == R.styleable.BottomSheetDialog_bsd_dimAmount)
            dimAmount(a.getFloat(attr, 0f));
        else if (attr == R.styleable.BottomSheetDialog_bsd_inDuration)
            inDuration(a.getInteger(attr, 0));
        else if (attr == R.styleable.BottomSheetDialog_bsd_inInterpolator) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0)
                inInterpolator(AnimationUtils.loadInterpolator(context, resId));
        } else if (attr == R.styleable.BottomSheetDialog_bsd_outDuration)
            outDuration(a.getInteger(attr, 0));
        else if (attr == R.styleable.BottomSheetDialog_bsd_outInterpolator) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0)
                outInterpolator(AnimationUtils.loadInterpolator(context, resId));
        }
    }
    a.recycle();
    if (mInInterpolator == null)
        mInInterpolator = new DecelerateInterpolator();
    if (mOutInterpolator == null)
        mOutInterpolator = new AccelerateInterpolator();
    return this;
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TypedArray(android.content.res.TypedArray)

Example 13 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project MagicIndicator by hackware1993.

the class BadgeTabExampleActivity method initMagicIndicator2.

private void initMagicIndicator2() {
    MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
    magicIndicator.setBackgroundColor(Color.WHITE);
    CommonNavigator commonNavigator = new CommonNavigator(this);
    commonNavigator.setAdjustMode(true);
    commonNavigator.setAdapter(new CommonNavigatorAdapter() {

        @Override
        public int getCount() {
            return mDataList == null ? 0 : mDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            BadgePagerTitleView badgePagerTitleView = new BadgePagerTitleView(context);
            SimplePagerTitleView simplePagerTitleView = new ScaleTransitionPagerTitleView(context);
            simplePagerTitleView.setText(mDataList.get(index));
            simplePagerTitleView.setTextSize(18);
            simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
            simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
            simplePagerTitleView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mViewPager.setCurrentItem(index);
                }
            });
            badgePagerTitleView.setInnerPagerTitleView(simplePagerTitleView);
            // setup badge
            if (index == 1) {
                ImageView badgeImageView = (ImageView) LayoutInflater.from(context).inflate(R.layout.simple_red_dot_badge_layout, null);
                badgePagerTitleView.setBadgeView(badgeImageView);
                badgePagerTitleView.setXBadgeRule(new BadgeRule(BadgeAnchor.CENTER_X, -UIUtil.dip2px(context, 3)));
                badgePagerTitleView.setYBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_BOTTOM, UIUtil.dip2px(context, 2)));
            }
            // cancel badge when click tab, default true
            badgePagerTitleView.setAutoCancelBadge(true);
            return badgePagerTitleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setStartInterpolator(new AccelerateInterpolator());
            indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
            indicator.setYOffset(UIUtil.dip2px(context, 39));
            indicator.setLineHeight(UIUtil.dip2px(context, 1));
            indicator.setColors(Color.parseColor("#f57c00"));
            return indicator;
        }

        @Override
        public float getTitleWeight(Context context, int index) {
            if (index == 0) {
                return 2.0f;
            } else if (index == 1) {
                return 1.2f;
            } else {
                return 1.0f;
            }
        }
    });
    magicIndicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Also used : Context(android.content.Context) BadgeRule(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.badge.BadgeRule) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) CommonNavigator(net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) IPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator) MagicIndicator(net.lucode.hackware.magicindicator.MagicIndicator) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ImageView(android.widget.ImageView) ClipPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView) View(android.view.View) BadgePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.badge.BadgePagerTitleView) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) ColorTransitionPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView) TextView(android.widget.TextView) BadgePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.badge.BadgePagerTitleView) CommonNavigatorAdapter(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) LinePagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator) ImageView(android.widget.ImageView)

Example 14 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project MagicIndicator by hackware1993.

the class FixedTabExampleActivity method initMagicIndicator2.

private void initMagicIndicator2() {
    MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
    magicIndicator.setBackgroundColor(Color.WHITE);
    CommonNavigator commonNavigator = new CommonNavigator(this);
    commonNavigator.setAdjustMode(true);
    commonNavigator.setAdapter(new CommonNavigatorAdapter() {

        @Override
        public int getCount() {
            return mDataList == null ? 0 : mDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            SimplePagerTitleView simplePagerTitleView = new ScaleTransitionPagerTitleView(context);
            simplePagerTitleView.setText(mDataList.get(index));
            simplePagerTitleView.setTextSize(18);
            simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
            simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
            simplePagerTitleView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mViewPager.setCurrentItem(index);
                }
            });
            return simplePagerTitleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setStartInterpolator(new AccelerateInterpolator());
            indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
            indicator.setYOffset(UIUtil.dip2px(context, 39));
            indicator.setLineHeight(UIUtil.dip2px(context, 1));
            indicator.setColors(Color.parseColor("#f57c00"));
            return indicator;
        }

        @Override
        public float getTitleWeight(Context context, int index) {
            if (index == 0) {
                return 2.0f;
            } else if (index == 1) {
                return 1.2f;
            } else {
                return 1.0f;
            }
        }
    });
    magicIndicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) CommonNavigator(net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) IPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator) MagicIndicator(net.lucode.hackware.magicindicator.MagicIndicator) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ClipPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView) View(android.view.View) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) ColorTransitionPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView) CommonNavigatorAdapter(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) LinePagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator)

Example 15 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project MagicIndicator by hackware1993.

the class ScrollableTabExampleActivity method initMagicIndicator5.

private void initMagicIndicator5() {
    MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator5);
    magicIndicator.setBackgroundColor(Color.WHITE);
    CommonNavigator commonNavigator = new CommonNavigator(this);
    commonNavigator.setScrollPivotX(0.8f);
    commonNavigator.setAdapter(new CommonNavigatorAdapter() {

        @Override
        public int getCount() {
            return mDataList == null ? 0 : mDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            SimplePagerTitleView simplePagerTitleView = new ScaleTransitionPagerTitleView(context);
            simplePagerTitleView.setText(mDataList.get(index));
            simplePagerTitleView.setTextSize(18);
            simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
            simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
            simplePagerTitleView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mViewPager.setCurrentItem(index);
                }
            });
            return simplePagerTitleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setStartInterpolator(new AccelerateInterpolator());
            indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
            indicator.setYOffset(UIUtil.dip2px(context, 39));
            indicator.setLineHeight(UIUtil.dip2px(context, 1));
            indicator.setColors(Color.parseColor("#f57c00"));
            return indicator;
        }
    });
    magicIndicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) CommonNavigator(net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) IPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator) MagicIndicator(net.lucode.hackware.magicindicator.MagicIndicator) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) ColorFlipPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ColorFlipPagerTitleView) ScaleTransitionPagerTitleView(net.lucode.hackware.magicindicatordemo.ext.titles.ScaleTransitionPagerTitleView) SimplePagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView) ClipPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView) View(android.view.View) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) ColorTransitionPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView) CommonNavigatorAdapter(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) LinePagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8