aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Geocache.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-03-15 23:35:21 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-03-15 23:35:21 +0100
commit89b499ee6ebc10b46d69d4e86fc83e2c330cbdb3 (patch)
tree3172c130024142a82a6db854824723dad5ef2a60 /main/src/cgeo/geocaching/Geocache.java
parent14478076cd9ab465f2dc6fdaef93c0167b398d54 (diff)
downloadcgeo-89b499ee6ebc10b46d69d4e86fc83e2c330cbdb3.zip
cgeo-89b499ee6ebc10b46d69d4e86fc83e2c330cbdb3.tar.gz
cgeo-89b499ee6ebc10b46d69d4e86fc83e2c330cbdb3.tar.bz2
fix #3661: add ability to open image from cache description
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
-rw-r--r--main/src/cgeo/geocaching/Geocache.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index 8dde37d..f6e3f18 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -47,18 +47,23 @@ import rx.functions.Action1;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
+import android.text.Html.ImageGetter;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -1710,12 +1715,34 @@ public class Geocache implements ICache, IWaypoint {
}
};
- public List<Image> getImages() {
- final List<Image> result = new ArrayList<Image>();
+ private void addDescriptionImagesUrls(final Collection<Image> images) {
+ final Set<String> urls = new LinkedHashSet<String>();
+ for (final Image image : images) {
+ urls.add(image.getUrl());
+ }
+ Html.fromHtml(getDescription(), new ImageGetter() {
+ @Override
+ public Drawable getDrawable(final String source) {
+ if (!urls.contains(source)) {
+ images.add(new Image(source, geocode));
+ urls.add(source);
+ }
+ return null;
+ }
+ }, null);
+ }
+
+ public Collection<Image> getImages() {
+ final LinkedList<Image> result = new LinkedList<Image>();
result.addAll(getSpoilers());
for (final LogEntry log : getLogs()) {
result.addAll(log.getLogImages());
}
+ final Set<String> urls = new HashSet<String>(result.size());
+ for (final Image image : result) {
+ urls.add(image.getUrl());
+ }
+ addDescriptionImagesUrls(result);
return result;
}