Search in sources :

Example 31 with TypedValue

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);
}
Also used : Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 32 with TypedValue

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 });
}
Also used : ColorStateList(android.content.res.ColorStateList) TypedValue(android.util.TypedValue)

Example 33 with TypedValue

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 });
}
Also used : ColorStateList(android.content.res.ColorStateList) TypedValue(android.util.TypedValue)

Example 34 with TypedValue

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TypedValue(android.util.TypedValue) Implementation(org.robolectric.annotation.Implementation)

Example 35 with TypedValue

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) TypedValue(android.util.TypedValue)

Aggregations

TypedValue (android.util.TypedValue)844 TypedArray (android.content.res.TypedArray)190 Resources (android.content.res.Resources)92 ContextThemeWrapper (android.view.ContextThemeWrapper)52 Context (android.content.Context)50 Drawable (android.graphics.drawable.Drawable)49 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)46 TextView (android.widget.TextView)44 Paint (android.graphics.Paint)41 IOException (java.io.IOException)39 AttributeSet (android.util.AttributeSet)34 View (android.view.View)30 XmlResourceParser (android.content.res.XmlResourceParser)29 Point (android.graphics.Point)26 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)26 ColorStateList (android.content.res.ColorStateList)23 DisplayMetrics (android.util.DisplayMetrics)23 LinearLayout (android.widget.LinearLayout)20 Bundle (android.os.Bundle)19 SpannableString (android.text.SpannableString)19