use of android.graphics.drawable.Drawable in project material-dialogs by afollestad.
the class MDTintHelper method setTint.
public static void setTint(@NonNull RadioButton radioButton, @NonNull ColorStateList colors) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setButtonTintList(colors);
} else {
Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
Drawable d = DrawableCompat.wrap(radioDrawable);
DrawableCompat.setTintList(d, colors);
radioButton.setButtonDrawable(d);
}
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class CarbonResources method createFromXmlInner.
/**
* Create a drawable from inside an XML document using an optional
* {@link Resources.Theme}. Called on a parser positioned at a tag in an XML
* document, tries to create a Drawable from that tag. Returns {@code null}
* if the tag is not a valid drawable.
*/
public Drawable createFromXmlInner(XmlPullParser parser, AttributeSet attrs, Resources.Theme theme) throws XmlPullParserException, IOException {
Drawable drawable = null;
final String name = parser.getName();
try {
Class<? extends Drawable> clazz = CLASS_MAP.get(name);
if (clazz != null) {
drawable = clazz.newInstance();
} else if (name.indexOf('.') > 0) {
drawable = (Drawable) Class.forName(name).newInstance();
}
} catch (Exception e) {
throw new XmlPullParserException("Error while inflating drawable resource", parser, e);
}
if (drawable == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Drawable.createFromXmlInner(this, parser, attrs, theme);
} else {
return Drawable.createFromXmlInner(this, parser, attrs);
}
}
IMPL.inflate(drawable, this, parser, attrs, theme);
return drawable;
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class CarbonResources method loadDrawable.
public Drawable loadDrawable(TypedValue value, Resources.Theme theme) throws Resources.NotFoundException {
if (value == null || value.resourceId == 0) {
return null;
}
final boolean isColorDrawable;
final LongSparseArray<WeakReference<Drawable.ConstantState>> cache;
final long key;
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
isColorDrawable = true;
cache = sColorDrawableCache;
key = value.data;
} else {
isColorDrawable = false;
cache = sDrawableCache;
key = (long) value.assetCookie << 32 | value.data;
}
Drawable dr = getCachedDrawable(cache, key);
if (dr != null) {
return dr;
}
Drawable.ConstantState cs = null;
if (cs != null) {
final Drawable cloneDr = cs.newDrawable(this);
if (theme != null) {
dr = cloneDr.mutate();
applyTheme(dr, theme);
} else {
dr = cloneDr;
}
} else if (isColorDrawable) {
dr = new ColorDrawable(value.data);
} else {
dr = loadDrawableForCookie(value, value.resourceId, theme);
}
if (dr != null) {
dr.setChangingConfigurations(value.changingConfigurations);
cacheDrawable(value, theme, isColorDrawable, key, dr, cache);
}
return dr;
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class CarbonResources method createFromXml.
/**
* Create a drawable from an XML document using an optional {@link Resources.Theme}.
* For more information on how to create resources in XML, see
* <a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>.
*/
public Drawable createFromXml(XmlPullParser parser, Resources.Theme theme) throws XmlPullParserException, IOException {
AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
// Empty loop
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
Drawable drawable = createFromXmlInner(parser, attrs, theme);
if (drawable == null) {
throw new RuntimeException("Unknown initial tag: " + parser.getName());
}
return drawable;
}
use of android.graphics.drawable.Drawable in project Carbon by ZieIony.
the class ToolbarWidgetWrapper method updateToolbarLogo.
private void updateToolbarLogo() {
Drawable logo = null;
if ((mDisplayOpts & ActionBar.DISPLAY_SHOW_HOME) != 0) {
if ((mDisplayOpts & ActionBar.DISPLAY_USE_LOGO) != 0) {
logo = mLogo != null ? mLogo : mIcon;
} else {
logo = mIcon;
}
}
mToolbar.setLogo(logo);
}
Aggregations