block = -1;
value.dataType = Res_value::TYPE_ATTRIBUTE;
value.data = srcValues[ii];
- DEBUG_STYLES(ALOGI("-> From values: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From values: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
- // Skip through the default style values until the end or the next possible match.
- while (defStyleEnt < endDefStyleEnt && curIdent > defStyleEnt->map.name.ident) {
- defStyleEnt++;
- }
- // Retrieve the current default style attribute if it matches, and step to next.
- if (defStyleEnt < endDefStyleEnt && curIdent == defStyleEnt->map.name.ident) {
- if (value.dataType == Res_value::TYPE_NULL) {
- block = defStyleEnt->stringBlock;
+ if (value.dataType == Res_value::TYPE_NULL) {
+ const ResTable::bag_entry* const defStyleEntry = defStyleAttrFinder.find(curIdent);
+ if (defStyleEntry != defStyleEnd) {
+ block = defStyleEntry->stringBlock;
typeSetFlags = defStyleTypeSetFlags;
- value = defStyleEnt->map.value;
+ value = defStyleEntry->map.value;
- DEBUG_STYLES(ALOGI("-> From def style: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
- defStyleEnt++;
}
uint32_t resid = 0;
// filling in each with whatever data we can find.
ssize_t block = 0;
uint32_t typeSetFlags;
- for (jsize ii=0; ii<NI; ii++) {
+ for (jsize ii = 0; ii < NI; ii++) {
const uint32_t curIdent = (uint32_t)src[ii];
- DEBUG_STYLES(ALOGI("RETRIEVING ATTR 0x%08x...", curIdent));
+ if (kDebugStyles) {
+ ALOGI("RETRIEVING ATTR 0x%08x...", curIdent);
+ }
// Try to find a value for this attribute... we prioritize values
// coming from, first XML attributes, then XML style, then default
typeSetFlags = 0;
config.density = 0;
- // Skip through XML attributes until the end or the next possible match.
- while (ix < NX && curIdent > curXmlAttr) {
- ix++;
- curXmlAttr = xmlParser->getAttributeNameResID(ix);
- }
- // Retrieve the current XML attribute if it matches, and step to next.
- if (ix < NX && curIdent == curXmlAttr) {
+ // Walk through the xml attributes looking for the requested attribute.
+ const jsize xmlAttrIdx = xmlAttrFinder.find(curIdent);
+ if (xmlAttrIdx != xmlAttrEnd) {
+ // We found the attribute we were looking for.
block = kXmlBlock;
- xmlParser->getAttributeValue(ix, &value);
- ix++;
- curXmlAttr = xmlParser->getAttributeNameResID(ix);
+ xmlParser->getAttributeValue(xmlAttrIdx, &value);
- DEBUG_STYLES(ALOGI("-> From XML: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From XML: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
- // Skip through the style values until the end or the next possible match.
- while (styleEnt < endStyleEnt && curIdent > styleEnt->map.name.ident) {
- styleEnt++;
- }
- // Retrieve the current style attribute if it matches, and step to next.
- if (styleEnt < endStyleEnt && curIdent == styleEnt->map.name.ident) {
- if (value.dataType == Res_value::TYPE_NULL) {
- block = styleEnt->stringBlock;
+ if (value.dataType == Res_value::TYPE_NULL) {
+ // Walk through the style class values looking for the requested attribute.
+ const ResTable::bag_entry* const styleAttrEntry = styleAttrFinder.find(curIdent);
+ if (styleAttrEntry != styleAttrEnd) {
+ // We found the attribute we were looking for.
+ block = styleAttrEntry->stringBlock;
typeSetFlags = styleTypeSetFlags;
- value = styleEnt->map.value;
+ value = styleAttrEntry->map.value;
- DEBUG_STYLES(ALOGI("-> From style: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From style: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
- styleEnt++;
}
- // Skip through the default style values until the end or the next possible match.
- while (defStyleEnt < endDefStyleEnt && curIdent > defStyleEnt->map.name.ident) {
- defStyleEnt++;
- }
- // Retrieve the current default style attribute if it matches, and step to next.
- if (defStyleEnt < endDefStyleEnt && curIdent == defStyleEnt->map.name.ident) {
- if (value.dataType == Res_value::TYPE_NULL) {
- block = defStyleEnt->stringBlock;
- typeSetFlags = defStyleTypeSetFlags;
- value = defStyleEnt->map.value;
+ if (value.dataType == Res_value::TYPE_NULL) {
+ // Walk through the default style values looking for the requested attribute.
+ const ResTable::bag_entry* const defStyleAttrEntry = defStyleAttrFinder.find(curIdent);
+ if (defStyleAttrEntry != defStyleAttrEnd) {
+ // We found the attribute we were looking for.
+ block = defStyleAttrEntry->stringBlock;
+ typeSetFlags = styleTypeSetFlags;
+ value = defStyleAttrEntry->map.value;
- DEBUG_STYLES(ALOGI("-> From def style: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
- defStyleEnt++;
}
uint32_t resid = 0;
// Take care of resolving the found resource to its final value.
ssize_t newBlock = theme->resolveAttributeReference(&value, block,
&resid, &typeSetFlags, &config);
- if (newBlock >= 0) block = newBlock;
+ if (newBlock >= 0) {
+ block = newBlock;
+ }
- DEBUG_STYLES(ALOGI("-> Resolved attr: type=0x%x, data=0x%08x",
- value.dataType, value.data));
++
+ if (kDebugStyles) {
+ ALOGI("-> Resolved attr: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
} else {
// If we still don't have a value for this attribute, try to find
// it in the theme!
ssize_t newBlock = theme->getAttribute(curIdent, &value, &typeSetFlags);
if (newBlock >= 0) {
- DEBUG_STYLES(ALOGI("-> From theme: type=0x%x, data=0x%08x",
- value.dataType, value.data));
+ if (kDebugStyles) {
+ ALOGI("-> From theme: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
newBlock = res.resolveReference(&value, block, &resid,
&typeSetFlags, &config);
-#if THROW_ON_BAD_ID
- if (newBlock == BAD_INDEX) {
- jniThrowException(env, "java/lang/IllegalStateException", "Bad resource!");
- return JNI_FALSE;
+ if (kThrowOnBadId) {
+ if (newBlock == BAD_INDEX) {
+ jniThrowException(env, "java/lang/IllegalStateException", "Bad resource!");
+ return JNI_FALSE;
+ }
}
- if (newBlock >= 0) block = newBlock;
-#endif
++
+ if (newBlock >= 0) {
+ block = newBlock;
+ }
- DEBUG_STYLES(ALOGI("-> Resolved theme: type=0x%x, data=0x%08x",
- value.dataType, value.data));
++
+ if (kDebugStyles) {
+ ALOGI("-> Resolved theme: type=0x%x, data=0x%08x", value.dataType, value.data);
+ }
}
}