use of net.qiujuer.genius.ui.drawable.CircleCheckDrawable in project Genius-Android by qiujuer.
the class CheckBox method init.
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final Context context = getContext();
final Resources resource = getResources();
final float density = resource.getDisplayMetrics().density;
final int baseSize = (int) (density * 2);
if (attrs == null) {
mMarkDrawable = new CircleCheckDrawable(resource.getColorStateList(R.color.g_default_check_box));
setButtonDrawable(mMarkDrawable);
return;
}
// Load attributes
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CheckBox, defStyleAttr, defStyleRes);
int borderSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gBorderSize, baseSize);
int intervalSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gIntervalSize, baseSize);
int markSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gMarkSize, -1);
ColorStateList color = a.getColorStateList(R.styleable.CheckBox_gMarkColor);
String fontFile = a.getString(R.styleable.CheckBox_gFont);
a.recycle();
if (color == null)
color = resource.getColorStateList(R.color.g_default_check_box);
boolean isCustom = true;
if (markSize < 0) {
markSize = (int) (density * 22);
isCustom = false;
}
mMarkDrawable = new CircleCheckDrawable(color);
mMarkDrawable.setBorderSize(borderSize);
mMarkDrawable.setIntervalSize(intervalSize);
mMarkDrawable.setMarkSize(markSize, isCustom);
mMarkDrawable.inEditMode(isInEditMode());
setButtonDrawable(mMarkDrawable);
// Check for IDE preview render
if (!this.isInEditMode()) {
// Font
if (fontFile != null && fontFile.length() > 0) {
Typeface typeface = Ui.getFont(getContext(), fontFile);
if (typeface != null)
setTypeface(typeface);
}
}
}
Aggregations