From c19ba6b9bb60fe8772637e529bd712fc7c481659 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 10 Apr 2018 15:08:09 +0300 Subject: [PATCH] Format wikivoyage article geographical description --- .../wikivoyage/data/WikivoyageArticle.java | 20 +++++++++++++++++++ .../explore/SavedArticlesRvAdapter.java | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java index 60c5cf823b..492021bfe7 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageArticle.java @@ -4,6 +4,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.Size; import android.text.Html; +import android.text.TextUtils; import net.osmand.plus.GPXUtilities.GPXFile; @@ -113,6 +114,25 @@ public class WikivoyageArticle { return res.toString(); } + @Nullable + public String getGeoDescription() { + if (TextUtils.isEmpty(aggregatedPartOf)) { + return null; + } + + String[] parts = aggregatedPartOf.split(","); + if (parts.length > 0) { + StringBuilder res = new StringBuilder(); + res.append(parts[parts.length - 1]); + if (parts.length > 1) { + res.append(" \u2022 ").append(parts[0]); + } + return res.toString(); + } + + return null; + } + @NonNull public static String getImageUrl(@NonNull String imageTitle, boolean thumbnail) { String[] hash = getHash(imageTitle); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 6e552b2a5a..2972d7249d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -68,7 +68,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter