From 3af97535dc61bdd3fb112760bfd8211efb1897d6 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 3 Apr 2018 15:33:40 +0300 Subject: [PATCH] Format WikivoyageArticleDialogFragment#createHtmlContent --- .../WikivoyageArticleDialogFragment.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 58c1056c7b..c82f75f5c0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.FragmentManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.Toolbar; +import android.text.TextUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -22,7 +23,6 @@ import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; -import net.osmand.util.Algorithms; import java.io.File; @@ -144,18 +144,21 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); } - private String createHtmlContent(WikivoyageArticle article) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(HEADER_INNER); - String articleTitle = article.getImageTitle(); - if (!Algorithms.isEmpty(articleTitle)) { - stringBuilder.append(""); - } - stringBuilder.append("
\n"); - stringBuilder.append("

").append(article.getTitle()).append("

"); - stringBuilder.append(article.getContent()).append(FOOTER_INNER); + @NonNull + private String createHtmlContent(@NonNull WikivoyageArticle article) { + StringBuilder sb = new StringBuilder(HEADER_INNER); - return stringBuilder.toString(); + String articleTitle = article.getImageTitle(); + if (!TextUtils.isEmpty(articleTitle)) { + String url = WikivoyageArticle.getImageUrl(articleTitle); + sb.append(""); + } + sb.append("
\n"); + sb.append("

").append(article.getTitle()).append("

"); + sb.append(article.getContent()); + sb.append(FOOTER_INNER); + + return sb.toString(); } @NonNull