From 597b7836055ac0448b82770d2579b82a7ab5805b Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 25 Jul 2014 12:48:26 +0200 Subject: No need to display the logs with smileys twice The log view now uses the background image loading process already used for caches and trackable descriptions. --- .../cgeo/geocaching/ui/logs/LogsViewCreator.java | 43 ++-------------------- 1 file changed, 3 insertions(+), 40 deletions(-) (limited to 'main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java') diff --git a/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java index e951394..9532946 100644 --- a/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java +++ b/main/src/cgeo/geocaching/ui/logs/LogsViewCreator.java @@ -4,13 +4,11 @@ import cgeo.geocaching.ImagesActivity; import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; import cgeo.geocaching.activity.AbstractActivity; -import cgeo.geocaching.activity.Progress; import cgeo.geocaching.list.StoredList; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.ui.AbstractCachingListViewPageViewCreator; import cgeo.geocaching.ui.AnchorAwareLinkMovementMethod; import cgeo.geocaching.ui.DecryptTextClickListener; -import cgeo.geocaching.ui.HtmlImageCounter; import cgeo.geocaching.ui.UserActionsClickListener; import cgeo.geocaching.utils.Formatter; import cgeo.geocaching.utils.TextUtils; @@ -18,9 +16,7 @@ import cgeo.geocaching.utils.UnknownTagsHandler; import org.apache.commons.lang3.StringEscapeUtils; -import android.os.AsyncTask; import android.text.Html; -import android.text.Spanned; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; @@ -88,17 +84,10 @@ public abstract class LogsViewCreator extends AbstractCachingListViewPageViewCre String logText = log.log; if (TextUtils.containsHtml(logText)) { logText = log.getDisplayText(); - // Fast preview: parse only HTML without loading any images - final HtmlImageCounter imageCounter = new HtmlImageCounter(); final UnknownTagsHandler unknownTagsHandler = new UnknownTagsHandler(); - holder.text.setText(Html.fromHtml(logText, imageCounter, unknownTagsHandler), TextView.BufferType.SPANNABLE); - if (imageCounter.getImageCount() > 0) { - // Complete view: parse again with loading images - if necessary ! If there are any images causing problems the user can see at least the preview - final LogImageLoader loader = new LogImageLoader(holder); - loader.execute(logText); - } - } - else { + holder.text.setText(Html.fromHtml(logText, new HtmlImage(getGeocode(), false, StoredList.STANDARD_LIST_ID, false, holder.text), + unknownTagsHandler), TextView.BufferType.SPANNABLE); + } else { holder.text.setText(logText, TextView.BufferType.SPANNABLE); } @@ -146,30 +135,4 @@ public abstract class LogsViewCreator extends AbstractCachingListViewPageViewCre abstract protected boolean isValid(); - /** Loads the Log Images outside the UI thread. */ - - private class LogImageLoader extends AsyncTask { - final private LogViewHolder holder; - final private int position; - - public LogImageLoader(final LogViewHolder holder) { - this.holder = holder; - this.position = holder.getPosition(); - } - - @Override - protected Spanned doInBackground(final String... logtext) { - return Html.fromHtml(logtext[0], new HtmlImage(getGeocode(), false, StoredList.STANDARD_LIST_ID, false), null); //, TextView.BufferType.SPANNABLE) - } - - @Override - protected void onPostExecute(final Spanned result) { - // Ensure that this holder and its view still references the right item before updating the text. - if (position == holder.getPosition()) { - holder.text.setText(result); - } - } - - } - } -- cgit v1.1