diff options
Diffstat (limited to 'main/src/cgeo/geocaching/ui/CacheDetailsCreator.java')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/CacheDetailsCreator.java | 15 |
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; } |
