aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java3
-rw-r--r--main/src/cgeo/geocaching/ui/AnchorAwareLinkMovementMethod.java37
2 files changed, 39 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 3e95d72..f35d599 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -19,6 +19,7 @@ import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.network.Network;
import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.ui.AbstractCachingPageViewCreator;
+import cgeo.geocaching.ui.AnchorAwareLinkMovementMethod;
import cgeo.geocaching.ui.CacheDetailsCreator;
import cgeo.geocaching.ui.DecryptTextClickListener;
import cgeo.geocaching.ui.Formatter;
@@ -1958,7 +1959,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
if (description != null) {
if (StringUtils.isNotBlank(descriptionString)) {
descriptionView.setText(description, TextView.BufferType.SPANNABLE);
- descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
+ descriptionView.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance());
fixBlackTextColor(descriptionView, descriptionString);
}
diff --git a/main/src/cgeo/geocaching/ui/AnchorAwareLinkMovementMethod.java b/main/src/cgeo/geocaching/ui/AnchorAwareLinkMovementMethod.java
new file mode 100644
index 0000000..db82e5c
--- /dev/null
+++ b/main/src/cgeo/geocaching/ui/AnchorAwareLinkMovementMethod.java
@@ -0,0 +1,37 @@
+package cgeo.geocaching.ui;
+
+import android.text.Spannable;
+import android.text.method.LinkMovementMethod;
+import android.view.MotionEvent;
+import android.widget.TextView;
+
+/**
+ * <code>LinkMovementMethod</code> with built-in suppression of errors for links, where the URL cannot be handled
+ * correctly by Android.
+ *
+ */
+public class AnchorAwareLinkMovementMethod extends LinkMovementMethod {
+
+ private AnchorAwareLinkMovementMethod() {
+ // singleton
+ }
+
+ private static final class Holder {
+ // initialization on demand holder
+ private static final AnchorAwareLinkMovementMethod INSTANCE = new AnchorAwareLinkMovementMethod();
+ }
+
+ public static AnchorAwareLinkMovementMethod getInstance() {
+ return Holder.INSTANCE;
+ }
+
+ @Override
+ public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
+ try {
+ return super.onTouchEvent(widget, buffer, event);
+ } catch (Exception e) {
+ // local links to anchors don't work
+ }
+ return false;
+ }
+}