aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler <bananeweizen@gmx.de>2014-06-09 16:36:59 +0200
committerMichael Keppler <bananeweizen@gmx.de>2014-06-09 16:36:59 +0200
commitb0fc0af35e8fba289e38d06e5536135b4e5b36a6 (patch)
tree17f952fd11c1c83f2269ca29cce2ce6fbc68d1b8
parent235b0d63c3d9f70b573530dea21a63f7c98a5d06 (diff)
downloadcgeo-b0fc0af35e8fba289e38d06e5536135b4e5b36a6.zip
cgeo-b0fc0af35e8fba289e38d06e5536135b4e5b36a6.tar.gz
cgeo-b0fc0af35e8fba289e38d06e5536135b4e5b36a6.tar.bz2
fix #3972: hide short description if contained in long description
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 76411a2..f0cb392 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -1508,17 +1508,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final String longDescription = cache.getDescription();
loadDescription(longDescription, longDescView, loadingView);
-
- // Hide the short description, if it is contained somewhere at the start of the long description.
- if (shortDescView != null) {
- final String shortDescription = cache.getShortDescription();
- if (StringUtils.isNotBlank(shortDescription)) {
- final int index = longDescription.indexOf(shortDescription);
- if (index >= 0 && index < 200) {
- shortDescView.setVisibility(View.GONE);
- }
- }
- }
}
private void warnPersonalNoteExceedsLimit() {
@@ -1611,6 +1600,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
fixTextColor(descriptionString);
descriptionView.setVisibility(View.VISIBLE);
addContextMenu(descriptionView);
+ potentiallyHideShortDescription();
}
}
@@ -1649,6 +1639,27 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}, Schedulers.io());
}
+ /**
+ * Hide the short description, if it is contained somewhere at the start of the long description.
+ */
+ public void potentiallyHideShortDescription() {
+ final View shortView = ButterKnife.findById(this, R.id.shortdesc);
+ if (shortView == null) {
+ return;
+ }
+ if (shortView.getVisibility() == View.GONE) {
+ return;
+ }
+ final String shortDescription = cache.getShortDescription();
+ if (StringUtils.isNotBlank(shortDescription)) {
+ final int index = StringUtils.indexOf(cache.getDescription(), shortDescription);
+ // allow up to 200 characters of HTML formatting
+ if (index >= 0 && index < 200) {
+ shortView.setVisibility(View.GONE);
+ }
+ }
+ }
+
private void ensureSaved() {
if (!cache.isOffline()) {
showToast(getString(R.string.info_cache_saved));