import net.qiujuer.genius.ui.Ui; //导入方法依赖的package包/类
private void initAttrs(Context context, Resources resources, boolean notEdit, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AbsSeekBar,
defStyleAttr, defStyleRes);
// Values
int max = a.getInteger(R.styleable.AbsSeekBar_gMax, mMax);
int min = a.getInteger(R.styleable.AbsSeekBar_gMin, mMin);
int value = a.getInteger(R.styleable.AbsSeekBar_gValue, mValue);
mMin = min;
mMax = Math.max(min + 1, max);
mValue = Math.max(min, Math.min(max, value));
// Colors
ColorStateList trackColor = a.getColorStateList(R.styleable.AbsSeekBar_gTrackColor);
ColorStateList thumbColor = a.getColorStateList(R.styleable.AbsSeekBar_gThumbColor);
ColorStateList scrubberColor = a.getColorStateList(R.styleable.AbsSeekBar_gScrubberColor);
ColorStateList rippleColor = a.getColorStateList(R.styleable.AbsSeekBar_gRippleColor);
ColorStateList indicatorColor = a.getColorStateList(R.styleable.AbsSeekBar_gIndicatorBackgroundColor);
// Size
int tickSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTickSize,
resources.getDimensionPixelSize(R.dimen.genius_seekBar_tickSize));
int thumbSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gThumbSize,
resources.getDimensionPixelSize(R.dimen.genius_seekBar_thumbSize));
int touchSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTouchSize,
resources.getDimensionPixelSize(R.dimen.genius_seekBar_touchSize));
int trackStroke = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTrackStroke,
resources.getDimensionPixelSize(R.dimen.genius_seekBar_trackStroke));
int scrubberStroke = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gScrubberStroke,
resources.getDimensionPixelSize(R.dimen.genius_seekBar_scrubberStroke));
// Other
int indicator = a.getInt(R.styleable.AbsSeekBar_gIndicator, 1);
mMirrorForRtl = a.getBoolean(R.styleable.AbsSeekBar_gMirrorForRtl, mMirrorForRtl);
mAllowTrackClick = a.getBoolean(R.styleable.AbsSeekBar_gAllowTrackClickToDrag, mAllowTrackClick);
mIndicatorFormatter = a.getString(R.styleable.AbsSeekBar_gIndicatorFormatter);
// Indicator TextAppearance
int textAppearanceId = a.getResourceId(R.styleable.AbsSeekBar_gIndicatorTextAppearance, R.style.Genius_Widget_BalloonMarker_TextAppearance);
String fontFile = a.getString(R.styleable.AbsSeekBar_gFont);
a.recycle();
// Set Size
mSeekBarDrawable.setTrackStroke(trackStroke);
mSeekBarDrawable.setScrubberStroke(scrubberStroke);
mSeekBarDrawable.setTouchRadius(touchSize);
mSeekBarDrawable.setTickRadius(tickSize);
mSeekBarDrawable.setThumbRadius(thumbSize);
// Set Colors
if (rippleColor != null)
mRipple.setColorStateList(rippleColor);
if (trackColor != null)
mSeekBarDrawable.setTrackColor(trackColor);
if (thumbColor != null)
mSeekBarDrawable.setThumbColor(thumbColor);
if (scrubberColor != null)
mSeekBarDrawable.setScrubberColor(scrubberColor);
if (notEdit && indicator != 0) {
mIndicator = new PopupIndicator(context);
mIndicator.setListener(mFloaterListener);
if (indicatorColor != null)
mIndicator.setIndicatorColor(indicatorColor);
mIndicator.setIndicatorTextAppearance(textAppearanceId);
mIndicator.setIndicatorClosedSize(thumbSize * 2);
// Font
if (fontFile != null && fontFile.length() > 0) {
Typeface typeface = Ui.getFont(getContext(), fontFile);
if (typeface != null) mIndicator.setTypeface(typeface);
}
}
// Enabled
setEnabled(attrs.getAttributeBooleanValue(Ui.androidStyleNameSpace, "enabled", isEnabled()));
}