Search in sources :

Example 31 with DecelerateInterpolator

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

the class Slider method applyStyle.

protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    getRippleManager().onCreate(this, context, attrs, defStyleAttr, defStyleRes);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider, defStyleAttr, defStyleRes);
    int minValue = getMinValue();
    int maxValue = getMaxValue();
    boolean valueRangeDefined = false;
    int value = -1;
    boolean valueDefined = false;
    String familyName = null;
    int style = Typeface.NORMAL;
    boolean textStyleDefined = false;
    for (int i = 0, count = a.getIndexCount(); i < count; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.Slider_sl_discreteMode)
            mDiscreteMode = a.getBoolean(attr, false);
        else if (attr == R.styleable.Slider_sl_primaryColor)
            mPrimaryColor = a.getColor(attr, 0);
        else if (attr == R.styleable.Slider_sl_secondaryColor)
            mSecondaryColor = a.getColor(attr, 0);
        else if (attr == R.styleable.Slider_sl_trackSize)
            mTrackSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_sl_trackCap) {
            int cap = a.getInteger(attr, 0);
            if (cap == 0)
                mTrackCap = Paint.Cap.BUTT;
            else if (cap == 1)
                mTrackCap = Paint.Cap.ROUND;
            else
                mTrackCap = Paint.Cap.SQUARE;
        } else if (attr == R.styleable.Slider_sl_thumbBorderSize)
            mThumbBorderSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_sl_thumbRadius)
            mThumbRadius = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_sl_thumbFocusRadius)
            mThumbFocusRadius = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_sl_thumbTouchRadius)
            mThumbTouchRadius = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_sl_travelAnimDuration) {
            mTravelAnimationDuration = a.getInteger(attr, 0);
            mTransformAnimationDuration = mTravelAnimationDuration;
        } else if (attr == R.styleable.Slider_sl_alwaysFillThumb) {
            mAlwaysFillThumb = a.getBoolean(R.styleable.Slider_sl_alwaysFillThumb, false);
        } else if (attr == R.styleable.Slider_sl_interpolator) {
            int resId = a.getResourceId(R.styleable.Slider_sl_interpolator, 0);
            mInterpolator = AnimationUtils.loadInterpolator(context, resId);
        } else if (attr == R.styleable.Slider_android_gravity)
            mGravity = a.getInteger(attr, 0);
        else if (attr == R.styleable.Slider_sl_minValue) {
            minValue = a.getInteger(attr, 0);
            valueRangeDefined = true;
        } else if (attr == R.styleable.Slider_sl_maxValue) {
            maxValue = a.getInteger(attr, 0);
            valueRangeDefined = true;
        } else if (attr == R.styleable.Slider_sl_stepValue)
            mStepValue = a.getInteger(attr, 0);
        else if (attr == R.styleable.Slider_sl_value) {
            value = a.getInteger(attr, 0);
            valueDefined = true;
        } else if (attr == R.styleable.Slider_sl_fontFamily) {
            familyName = a.getString(attr);
            textStyleDefined = true;
        } else if (attr == R.styleable.Slider_sl_textStyle) {
            style = a.getInteger(attr, 0);
            textStyleDefined = true;
        } else if (attr == R.styleable.Slider_sl_textColor)
            mTextColor = a.getColor(attr, 0);
        else if (attr == R.styleable.Slider_sl_textSize)
            mTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.Slider_android_enabled)
            setEnabled(a.getBoolean(attr, true));
        else if (attr == R.styleable.Slider_sl_baselineOffset)
            mBaselineOffset = a.getDimensionPixelOffset(attr, 0);
    }
    a.recycle();
    if (mTrackSize < 0)
        mTrackSize = ThemeUtil.dpToPx(context, 2);
    if (mThumbBorderSize < 0)
        mThumbBorderSize = ThemeUtil.dpToPx(context, 2);
    if (mThumbRadius < 0)
        mThumbRadius = ThemeUtil.dpToPx(context, 10);
    if (mThumbFocusRadius < 0)
        mThumbFocusRadius = ThemeUtil.dpToPx(context, 14);
    if (mTravelAnimationDuration < 0) {
        mTravelAnimationDuration = context.getResources().getInteger(android.R.integer.config_mediumAnimTime);
        mTransformAnimationDuration = mTravelAnimationDuration;
    }
    if (mInterpolator == null)
        mInterpolator = new DecelerateInterpolator();
    if (valueRangeDefined)
        setValueRange(minValue, maxValue, false);
    if (valueDefined)
        setValue(value, false);
    else if (mThumbPosition < 0)
        setValue(mMinValue, false);
    if (textStyleDefined)
        mTypeface = TypefaceUtil.load(context, familyName, style);
    if (mTextSize < 0)
        mTextSize = context.getResources().getDimensionPixelOffset(R.dimen.abc_text_size_small_material);
    mPaint.setTextSize(mTextSize);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTypeface(mTypeface);
    measureText();
    invalidate();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TypedArray(android.content.res.TypedArray) Paint(android.graphics.Paint)

Example 32 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator 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 33 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator 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 34 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator 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 35 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator 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

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