Format wikivoyage article geographical description

This commit is contained in:
Alex Sytnyk 2018-04-10 15:08:09 +03:00
parent baa5bee92e
commit c19ba6b9bb
2 changed files with 21 additions and 1 deletions

View file

@ -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);

View file

@ -68,7 +68,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
holder.title.setText(article.getTitle());
holder.content.setText(article.getContent());
holder.partOf.setText(article.getAggregatedPartOf()); // todo
holder.partOf.setText(article.getGeoDescription());
holder.icon.setVisibility(View.GONE); // todo
holder.leftButton.setText(app.getString(R.string.shared_string_read));
holder.leftButton.setCompoundDrawablesWithIntrinsicBounds(readIcon, null, null, null);