Lines Matching refs:value

73      * Returns the color value represented by the given string value
74 * @param value the color value
78 public static int getColor(String value) {
79 if (value != null) {
80 if (!value.startsWith("#")) {
81 if (value.startsWith(SdkConstants.PREFIX_THEME_REF)) {
83 "Attribute '%s' not found. Are you using the right theme?", value));
86 String.format("Color value '%s' must start with #", value));
89 value = value.substring(1);
92 if (value.length() > 8) {
94 "Color value '%s' is too long. Format is either" +
96 value));
99 if (value.length() == 3) { // RGB format
102 color[2] = color[3] = value.charAt(0);
103 color[4] = color[5] = value.charAt(1);
104 color[6] = color[7] = value.charAt(2);
105 value = new String(color);
106 } else if (value.length() == 4) { // ARGB format
108 color[0] = color[1] = value.charAt(0);
109 color[2] = color[3] = value.charAt(1);
110 color[4] = color[5] = value.charAt(2);
111 color[6] = color[7] = value.charAt(3);
112 value = new String(color);
113 } else if (value.length() == 6) {
114 value = "FF" + value;
117 // this is a RRGGBB or AARRGGBB value
122 return (int)Long.parseLong(value, 16);
131 * @param resValue the value containing a color value or a file path to a complex color
141 String value = resValue.getValue();
142 if (value == null || RenderResources.REFERENCE_NULL.equals(value)) {
147 // first check if the value is a file (xml most likely)
151 parser = context.getLayoutlibCallback().getXmlFileParser(value);
154 File f = new File(value);
162 "Failed to parse file " + value, e, null /*data*/);
202 "Failed to configure parser for " + value, e, null /*data*/);
208 "Failed to parse file " + value, e, null /*data*/);
215 int color = getColor(value);
219 "Failed to convert " + value + " into a ColorStateList", e,
230 * @param resValue the value containing a color value or a file path to a complex color
244 * @param resValue the value containing a color value or a file path to a complex color
255 * Returns a drawable from the given value.
256 * @param value The value that contains a path to a 9 patch, a bitmap or a xml based drawable,
260 public static Drawable getDrawable(ResourceValue value, BridgeContext context) {
261 return getDrawable(value, context, null);
265 * Returns a drawable from the given value.
266 * @param value The value that contains a path to a 9 patch, a bitmap or a xml based drawable,
271 public static Drawable getDrawable(ResourceValue value, BridgeContext context, Theme theme) {
272 if (value == null) {
275 String stringValue = value.getValue();
283 if (value instanceof DensityBasedResourceValue) {
285 ((DensityBasedResourceValue)value).getResourceDensity();
294 new FileInputStream(file), density, value.isFramework(),
313 parser, context, value.isFramework());
337 value.isFramework() ? null : context.getProjectKey());
343 value.isFramework() ? null : context.getProjectKey());
353 // attempt to get a color from the value
421 * @param defaultValue the default value.
423 * @return the value of the attribute or the default one if not found.
427 ResourceValue value = resources.findItemInTheme(name, isFrameworkAttr);
428 value = resources.resolveResValue(value);
429 if (value == null) {
432 return XmlUtils.convertValueToBoolean(value.getValue(), defaultValue);
465 * Returns the raw value from the given attribute float-type value string.
468 public static TypedValue getValue(String attribute, String value, boolean requireUnit) {
469 if (parseFloatAttribute(attribute, value, mValue, requireUnit)) {
477 * Parse a float attribute and return the parsed value into a given TypedValue.
479 * @param value the string value of the attribute
480 * @param outValue the TypedValue to receive the parsed value
481 * @param requireUnit whether the value is expected to contain a unit.
484 public static boolean parseFloatAttribute(String attribute, @NonNull String value,
489 value = value.trim();
490 int len = value.length();
497 char[] buf = value.toCharArray();
510 Matcher m = sFloatPattern.matcher(value);
548 value, attribute),
559 private static void computeTypedValue(TypedValue outValue, float value, float scale) {
560 value *= scale;
561 boolean neg = value < 0;
563 value = -value;
565 long bits = (long)(value*(1<<23)+.5f);