use of com.android.ide.common.rendering.api.ResourceValue in project android_frameworks_base by ParanoidAndroid.
the class BridgeResources method getXml.
@Override
public XmlResourceParser getXml(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
String v = value.getSecond().getValue();
if (v != null) {
// check this is a file
File f = new File(v);
if (f.isFile()) {
try {
XmlPullParser parser = ParserFactory.create(f);
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
} catch (XmlPullParserException e) {
NotFoundException newE = new NotFoundException();
newE.initCause(e);
throw newE;
} catch (FileNotFoundException e) {
NotFoundException newE = new NotFoundException();
newE.initCause(e);
throw newE;
}
}
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(id);
// this is not used since the method above always throws
return null;
}
use of com.android.ide.common.rendering.api.ResourceValue in project android_frameworks_base by ParanoidAndroid.
the class BridgeResources method getBoolean.
@Override
public boolean getBoolean(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
ResourceValue resValue = value.getSecond();
assert resValue != null;
if (resValue != null) {
String v = resValue.getValue();
if (v != null) {
return Boolean.parseBoolean(v);
}
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(id);
// this is not used since the method above always throws
return false;
}
use of com.android.ide.common.rendering.api.ResourceValue in project android_frameworks_base by ParanoidAndroid.
the class BridgeResources method getInteger.
@Override
public int getInteger(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
ResourceValue resValue = value.getSecond();
assert resValue != null;
if (resValue != null) {
String v = resValue.getValue();
if (v != null) {
int radix = 10;
if (v.startsWith("0x")) {
v = v.substring(2);
radix = 16;
}
try {
return Integer.parseInt(v, radix);
} catch (NumberFormatException e) {
// return exception below
}
}
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(id);
// this is not used since the method above always throws
return 0;
}
use of com.android.ide.common.rendering.api.ResourceValue in project android_frameworks_base by ParanoidAndroid.
the class BridgeResources method getDimensionPixelOffset.
@Override
public int getDimensionPixelOffset(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
ResourceValue resValue = value.getSecond();
assert resValue != null;
if (resValue != null) {
String v = resValue.getValue();
if (v != null) {
if (ResourceHelper.parseFloatAttribute(value.getFirst(), v, mTmpValue, true) && mTmpValue.type == TypedValue.TYPE_DIMENSION) {
return TypedValue.complexToDimensionPixelOffset(mTmpValue.data, getDisplayMetrics());
}
}
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(id);
// this is not used since the method above always throws
return 0;
}
use of com.android.ide.common.rendering.api.ResourceValue in project android_frameworks_base by ParanoidAndroid.
the class BridgeTypedArray method getDrawable.
/**
* Retrieve the Drawable for the attribute at <var>index</var>. This
* gets the resource ID of the selected attribute, and uses
* {@link Resources#getDrawable Resources.getDrawable} of the owning
* Resources object to retrieve its Drawable.
*
* @param index Index of attribute to retrieve.
*
* @return Drawable for the attribute, or null if not defined.
*/
@Override
public Drawable getDrawable(int index) {
if (index < 0 || index >= mResourceData.length) {
return null;
}
if (mResourceData[index] == null) {
return null;
}
ResourceValue value = mResourceData[index];
String stringValue = value.getValue();
if (stringValue == null || RenderResources.REFERENCE_NULL.equals(stringValue)) {
return null;
}
return ResourceHelper.getDrawable(value, mContext);
}
Aggregations