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();
}
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;
}
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);
}
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);
}
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);
}
Aggregations