Use 800-px header images for wikivoyage articles

This commit is contained in:
Alex Sytnyk 2018-04-04 19:03:52 +03:00
parent d9b641c420
commit 35cfce08a2
3 changed files with 6 additions and 10 deletions

View file

@ -158,7 +158,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
String articleTitle = article.getImageTitle();
if (!TextUtils.isEmpty(articleTitle)) {
String url = WikivoyageArticle.getImageUrl(articleTitle);
String url = WikivoyageArticle.getImageUrl(articleTitle, false);
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
}
sb.append("<div class=\"main\">\n");

View file

@ -12,6 +12,7 @@ public class WikivoyageArticle {
private static final String IMAGE_ROOT_URL = "https://upload.wikimedia.org/wikipedia/commons/";
private static final String THUMB_PREFIX = "320px-";
private static final String REGULAR_PREFIX = "800px-";
String id;
String title;
@ -75,15 +76,10 @@ public class WikivoyageArticle {
}
@NonNull
public static String getThumbImageUrl(@NonNull String imageTitle) {
public static String getImageUrl(@NonNull String imageTitle, boolean thumbnail) {
String[] hash = getHash(imageTitle);
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + THUMB_PREFIX + imageTitle;
}
@NonNull
public static String getImageUrl(@NonNull String imageTitle) {
String[] hash = getHash(imageTitle);
return IMAGE_ROOT_URL + hash[0] + "/" + hash[1] + "/" + imageTitle;
String prefix = thumbnail ? THUMB_PREFIX : REGULAR_PREFIX;
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + prefix + imageTitle;
}
@Size(2)

View file

@ -74,7 +74,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
if (item instanceof WikivoyageSearchResult) {
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
Picasso.get()
.load(WikivoyageArticle.getThumbImageUrl(searchRes.getImageTitle()))
.load(WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true))
.transform(new CropCircleTransformation())
.placeholder(placeholder)
.into(holder.icon);