use of android.util.TypedValue in project iosched by google.
the class BaseActivity method shouldBeFloatingWindow.
/**
* Returns true if the theme sets the {@code R.attr.isFloatingWindow} flag to true.
*/
protected boolean shouldBeFloatingWindow() {
Resources.Theme theme = getTheme();
TypedValue floatingWindowFlag = new TypedValue();
// Check isFloatingWindow flag is defined in theme.
if (theme == null || !theme.resolveAttribute(R.attr.isFloatingWindow, floatingWindowFlag, true)) {
return false;
}
return (floatingWindowFlag.data != 0);
}
use of android.util.TypedValue in project material-components-android by material-components.
the class BottomNavigationView method createDefaultColorStateList.
private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
final TypedValue value = new TypedValue();
if (!getContext().getTheme().resolveAttribute(baseColorThemeAttr, value, true)) {
return null;
}
ColorStateList baseColor = AppCompatResources.getColorStateList(getContext(), value.resourceId);
if (!getContext().getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.colorPrimary, value, true)) {
return null;
}
int colorPrimary = value.data;
int defaultColor = baseColor.getDefaultColor();
return new ColorStateList(new int[][] { DISABLED_STATE_SET, CHECKED_STATE_SET, EMPTY_STATE_SET }, new int[] { baseColor.getColorForState(DISABLED_STATE_SET, defaultColor), colorPrimary, defaultColor });
}
use of android.util.TypedValue in project material-components-android by material-components.
the class NavigationView method createDefaultColorStateList.
private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
final TypedValue value = new TypedValue();
if (!getContext().getTheme().resolveAttribute(baseColorThemeAttr, value, true)) {
return null;
}
ColorStateList baseColor = AppCompatResources.getColorStateList(getContext(), value.resourceId);
if (!getContext().getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.colorPrimary, value, true)) {
return null;
}
int colorPrimary = value.data;
int defaultColor = baseColor.getDefaultColor();
return new ColorStateList(new int[][] { DISABLED_STATE_SET, CHECKED_STATE_SET, EMPTY_STATE_SET }, new int[] { baseColor.getColorForState(DISABLED_STATE_SET, defaultColor), colorPrimary, defaultColor });
}
use of android.util.TypedValue in project robolectric by robolectric.
the class ShadowResources method loadDrawable.
@Implementation
public Drawable loadDrawable(TypedValue value, int id, Resources.Theme theme) throws Resources.NotFoundException {
Drawable drawable = directlyOn(realResources, Resources.class, "loadDrawable", ClassParameter.from(TypedValue.class, value), ClassParameter.from(int.class, id), ClassParameter.from(Resources.Theme.class, theme));
setCreatedFromResId(realResources, id, drawable);
return drawable;
}
use of android.util.TypedValue in project robolectric by robolectric.
the class ShadowResourcesImpl method loadDrawable.
@Implementation
public Drawable loadDrawable(Resources wrapper, TypedValue value, int id, Resources.Theme theme, boolean useCache) throws Resources.NotFoundException {
Drawable drawable = directlyOn(realResourcesImpl, ResourcesImpl.class, "loadDrawable", from(Resources.class, wrapper), from(TypedValue.class, value), from(int.class, id), from(Resources.Theme.class, theme), from(boolean.class, useCache));
ShadowResources.setCreatedFromResId(wrapper, id, drawable);
return drawable;
}
Aggregations