From f44a56394254731f63eb279073f2949b09966aa1 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 8 Mar 2015 22:33:17 +0100 Subject: fix #4727: images in short description are absent from images tab --- main/src/cgeo/geocaching/Geocache.java | 2 +- main/src/cgeo/geocaching/Trackable.java | 2 +- main/src/cgeo/geocaching/utils/ImageUtils.java | 27 +++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'main') diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 8e9485e..67af107 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -1682,7 +1682,7 @@ public class Geocache implements IWaypoint { for (final LogEntry log : getLogs()) { result.addAll(log.getLogImages()); } - ImageUtils.addImagesFromHtml(result, getDescription(), geocode); + ImageUtils.addImagesFromHtml(result, geocode, getShortDescription(), getDescription()); return result; } diff --git a/main/src/cgeo/geocaching/Trackable.java b/main/src/cgeo/geocaching/Trackable.java index f93ec7b..d7d2357 100644 --- a/main/src/cgeo/geocaching/Trackable.java +++ b/main/src/cgeo/geocaching/Trackable.java @@ -227,7 +227,7 @@ public class Trackable implements ILogable { if (StringUtils.isNotBlank(image)) { images.add(new Image(image, StringUtils.defaultIfBlank(name, geocode))); } - ImageUtils.addImagesFromHtml(images, getDetails(), geocode); + ImageUtils.addImagesFromHtml(images, geocode, getDetails()); for (final LogEntry log : getLogs()) { images.addAll(log.getLogImages()); } diff --git a/main/src/cgeo/geocaching/utils/ImageUtils.java b/main/src/cgeo/geocaching/utils/ImageUtils.java index 9011ab9..71d5e39 100644 --- a/main/src/cgeo/geocaching/utils/ImageUtils.java +++ b/main/src/cgeo/geocaching/utils/ImageUtils.java @@ -320,26 +320,27 @@ public final class ImageUtils { /** * Add images present in the HTML description to the existing collection. - * - * @param images a collection of images - * @param htmlText the HTML description to be parsed + * @param images a collection of images * @param geocode the common title for images in the description + * @param htmlText the HTML description to be parsed, can be repeated */ - public static void addImagesFromHtml(final Collection images, final String htmlText, final String geocode) { + public static void addImagesFromHtml(final Collection images, final String geocode, final String... htmlText) { final Set urls = new LinkedHashSet<>(); for (final Image image : images) { urls.add(image.getUrl()); } - Html.fromHtml(StringUtils.defaultString(htmlText), new ImageGetter() { - @Override - public Drawable getDrawable(final String source) { - if (!urls.contains(source) && canBeOpenedExternally(source)) { - images.add(new Image(source, StringUtils.defaultString(geocode))); - urls.add(source); + for (final String text: htmlText) { + Html.fromHtml(StringUtils.defaultString(text), new ImageGetter() { + @Override + public Drawable getDrawable(final String source) { + if (!urls.contains(source) && canBeOpenedExternally(source)) { + images.add(new Image(source, StringUtils.defaultString(geocode))); + urls.add(source); + } + return null; } - return null; - } - }, null); + }, null); + } } /** -- cgit v1.1