Add support for images in gpx metadata

This commit is contained in:
Chumva 2019-07-04 16:33:49 +03:00
parent d0790075d8
commit 2b93241ae1

View file

@ -482,21 +482,31 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
@Nullable @Nullable
private String getMetadataDescription(@NonNull GPXUtilities.Metadata metadata) { private String getMetadataDescription(@NonNull GPXUtilities.Metadata metadata) {
String description = metadata.desc; String descHtml = metadata.desc;
if (TextUtils.isEmpty(description)) { if (TextUtils.isEmpty(descHtml)) {
Map<String, String> extensions = metadata.getExtensionsToRead(); Map<String, String> extensions = metadata.getExtensionsToRead();
if (!extensions.isEmpty() && extensions.containsKey("desc")) { if (!extensions.isEmpty() && extensions.containsKey("desc")) {
description = extensions.get("desc"); descHtml = extensions.get("desc");
} }
} }
return description != null ? Html.fromHtml(description).toString().trim() : null; if (descHtml != null) {
String content = WikiArticleHelper.getPartialContent(descHtml);
if (!TextUtils.isEmpty(content)) {
return content;
}
}
return descHtml;
} }
@Nullable @Nullable
private String getMetadataImageLink(@NonNull GPXUtilities.Metadata metadata) { private String getMetadataImageLink(@NonNull GPXUtilities.Metadata metadata) {
String link = metadata.link; String link = metadata.link;
if (!TextUtils.isEmpty(link)) {
return link; if (link.contains(".jpg") || link.contains(".gif") || link.contains(".jpeg") || link.contains(".png") || link.contains(".bmp") || link.contains(".webp")) {
return link;
}
}
return null;
} }
@Nullable @Nullable