mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
#3780 Create media using a combination of Entities & MwQueryResult - replace old site of thumbnail title with most relevant caption
This commit is contained in:
parent
eb9e94c603
commit
f96308e435
4 changed files with 5 additions and 20 deletions
|
|
@ -294,9 +294,9 @@ public class Media implements Parcelable {
|
||||||
return String.format("[[%s|thumb|%s]]", filename, getMostRelevantCaption());
|
return String.format("[[%s|thumb|%s]]", filename, getMostRelevantCaption());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMostRelevantCaption() {
|
public String getMostRelevantCaption() {
|
||||||
final String languageAppropriateCaption = captions.get(Locale.getDefault().getLanguage());
|
final String languageAppropriateCaption = captions.get(Locale.getDefault().getLanguage());
|
||||||
if(languageAppropriateCaption!=null){
|
if (languageAppropriateCaption != null) {
|
||||||
return languageAppropriateCaption;
|
return languageAppropriateCaption;
|
||||||
}
|
}
|
||||||
for (String firstCaption : captions.values()) {
|
for (String firstCaption : captions.values()) {
|
||||||
|
|
|
||||||
|
|
@ -88,19 +88,12 @@ public class GridViewAdapter extends ArrayAdapter {
|
||||||
SimpleDraweeView imageView = convertView.findViewById(R.id.categoryImageView);
|
SimpleDraweeView imageView = convertView.findViewById(R.id.categoryImageView);
|
||||||
TextView fileName = convertView.findViewById(R.id.categoryImageTitle);
|
TextView fileName = convertView.findViewById(R.id.categoryImageTitle);
|
||||||
TextView author = convertView.findViewById(R.id.categoryImageAuthor);
|
TextView author = convertView.findViewById(R.id.categoryImageAuthor);
|
||||||
fileName.setText(getTitle(item));
|
fileName.setText(item.getMostRelevantCaption());
|
||||||
setAuthorView(item, author);
|
setAuthorView(item, author);
|
||||||
imageView.setImageURI(item.getThumbUrl());
|
imageView.setImageURI(item.getThumbUrl());
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTitle(Media item) {
|
|
||||||
for (String caption : item.getCaptions().values()) {
|
|
||||||
return caption;
|
|
||||||
}
|
|
||||||
return item.getDisplayTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Media item at the given position
|
* @return the Media item at the given position
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
public void init(final int position, final Contribution contribution) {
|
public void init(final int position, final Contribution contribution) {
|
||||||
this.contribution = contribution;
|
this.contribution = contribution;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
titleView.setText(getTitle(contribution));
|
titleView.setText(contribution.getMostRelevantCaption());
|
||||||
final String imageSource = chooseImageSource(contribution.getThumbUrl(),
|
final String imageSource = chooseImageSource(contribution.getThumbUrl(),
|
||||||
contribution.getLocalUri());
|
contribution.getLocalUri());
|
||||||
if (!TextUtils.isEmpty(imageSource)) {
|
if (!TextUtils.isEmpty(imageSource)) {
|
||||||
|
|
@ -111,14 +111,6 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTitle(Contribution contribution) {
|
|
||||||
for (String value : contribution.getCaptions().values()) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return contribution.getDisplayTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a media exists on the corresponding Wikipedia article Currently the check is made for
|
* Checks if a media exists on the corresponding Wikipedia article Currently the check is made for
|
||||||
* the device's current language Wikipedia
|
* the device's current language Wikipedia
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class SearchImagesViewHolder(containerView: View, val onImageClicked: (Int) -> U
|
||||||
override fun bind(item: Pair<Media, Int>) {
|
override fun bind(item: Pair<Media, Int>) {
|
||||||
val media = item.first
|
val media = item.first
|
||||||
categoryImageView.setOnClickListener { onImageClicked(item.second) }
|
categoryImageView.setOnClickListener { onImageClicked(item.second) }
|
||||||
categoryImageTitle.text = media.displayTitle
|
categoryImageTitle.text = media.mostRelevantCaption
|
||||||
categoryImageView.setImageURI(media.thumbUrl)
|
categoryImageView.setImageURI(media.thumbUrl)
|
||||||
if (media.creator?.isNotEmpty() == true) {
|
if (media.creator?.isNotEmpty() == true) {
|
||||||
categoryImageAuthor.visibility = View.VISIBLE
|
categoryImageAuthor.visibility = View.VISIBLE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue