aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CacheDetailActivity.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-04-21 11:27:29 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-04-21 11:27:29 +0200
commitfb453e599fed716636b6056739f17e318d55d25c (patch)
tree0b50af7331b93c5abca433a582f16521de7e0f6c /main/src/cgeo/geocaching/CacheDetailActivity.java
parent47ae07d7cec5d0a4e3a6b6f7bc79f03ef055716e (diff)
downloadcgeo-fb453e599fed716636b6056739f17e318d55d25c.zip
cgeo-fb453e599fed716636b6056739f17e318d55d25c.tar.gz
cgeo-fb453e599fed716636b6056739f17e318d55d25c.tar.bz2
refactorings
* always use CacheAttribute for attribute strings * avoid concatenation in append * use SparseArray instead of maps
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java21
1 files changed, 5 insertions, 16 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 7a74dbc..92df3be 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -1217,11 +1217,6 @@ public class CacheDetailActivity extends AbstractActivity {
noAttributeIconsFound = true;
for (String attributeName : cache.getAttributes()) {
- boolean strikethru = attributeName.endsWith("_no");
- // cut off _yes / _no
- if (attributeName.endsWith("_no") || attributeName.endsWith("_yes")) {
- attributeName = attributeName.substring(0, attributeName.lastIndexOf('_'));
- }
// check if another attribute icon fits in this row
attributeRow.measure(0, 0);
int rowWidth = attributeRow.getMeasuredWidth();
@@ -1233,7 +1228,8 @@ public class CacheDetailActivity extends AbstractActivity {
rows.addView(attributeRow);
}
- CacheAttribute attrib = CacheAttribute.getByGcRawName(attributeName);
+ final boolean strikethru = !CacheAttribute.isEnabled(attributeName);
+ final CacheAttribute attrib = CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attributeName));
if (attrib != CacheAttribute.UNKNOWN) {
noAttributeIconsFound = false;
Drawable d = res.getDrawable(attrib.drawableId);
@@ -1275,18 +1271,11 @@ public class CacheDetailActivity extends AbstractActivity {
final List<String> attributes = cache.getAttributes();
for (String attributeName : attributes) {
- boolean negated = attributeName.endsWith("_no");
- // cut off _yes / _no
- if (attributeName.endsWith("_no") || attributeName.endsWith("_yes")) {
- attributeName = attributeName.substring(0, attributeName.lastIndexOf('_'));
- }
+ final boolean enabled = CacheAttribute.isEnabled(attributeName);
// search for a translation of the attribute
- CacheAttribute attrib = CacheAttribute.getByGcRawName(attributeName);
+ CacheAttribute attrib = CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attributeName));
if (attrib != CacheAttribute.UNKNOWN) {
- String translated = res.getString(negated ? attrib.stringIdNo : attrib.stringIdYes);
- if (StringUtils.isNotBlank(translated)) {
- attributeName = translated;
- }
+ attributeName = attrib.getL10n(enabled);
}
if (buffer.length() > 0) {
buffer.append('\n');