aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-12-16 20:17:03 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-12-16 20:39:33 +0100
commite266072c603ad721fc385994c498d5bbf27c9b5b (patch)
treea724b50491eaad6398e10dafae6b886976fea035 /main/src/cgeo/geocaching/ui
parentf08614446299a51e08070145c49383d23d4d61e8 (diff)
downloadcgeo-e266072c603ad721fc385994c498d5bbf27c9b5b.zip
cgeo-e266072c603ad721fc385994c498d5bbf27c9b5b.tar.gz
cgeo-e266072c603ad721fc385994c498d5bbf27c9b5b.tar.bz2
Keep a reference on the whole "name: value" line in description
Diffstat (limited to 'main/src/cgeo/geocaching/ui')
-rw-r--r--main/src/cgeo/geocaching/ui/CacheDetailsCreator.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java
index 55e9cfc..13887c0 100644
--- a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java
+++ b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java
@@ -12,6 +12,7 @@ import cgeo.geocaching.location.Units;
import cgeo.geocaching.utils.Formatter;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.eclipse.jdt.annotation.NonNull;
import android.annotation.SuppressLint;
@@ -45,18 +46,20 @@ public final class CacheDetailsCreator {
}
/**
- * @param nameId
- * @param value
- * @return the view containing the displayed string (i.e. the right side one from the pair of "label": "value")
+ * Create a "name: value" line.
+ *
+ * @param nameId the resource of the name field
+ * @param value the initial value
+ * @return a pair made of the whole "name: value" line (to be able to hide it for example) and of the value (to update it)
*/
- public TextView add(final int nameId, final CharSequence value) {
+ public ImmutablePair<RelativeLayout, TextView> add(final int nameId, final CharSequence value) {
final RelativeLayout layout = (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.cache_information_item, null, false);
final TextView nameView = ButterKnife.findById(layout, R.id.name);
nameView.setText(res.getString(nameId));
lastValueView = ButterKnife.findById(layout, R.id.value);
lastValueView.setText(value);
parentView.addView(layout);
- return lastValueView;
+ return ImmutablePair.of(layout, lastValueView);
}
public TextView getValueView() {
@@ -209,7 +212,7 @@ public final class CacheDetailsCreator {
if (StringUtils.isEmpty(dateString)) {
return null;
}
- final TextView view = add(cache.isEventCache() ? R.string.cache_event : R.string.cache_hidden, dateString);
+ final TextView view = add(cache.isEventCache() ? R.string.cache_event : R.string.cache_hidden, dateString).right;
view.setId(R.id.date);
return view;
}