mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
#3752 Media details do not show depiction - make request return all languages available and choose preferred or first (#3761)
This commit is contained in:
parent
3f31c3eded
commit
618ace707b
2 changed files with 8 additions and 5 deletions
|
|
@ -208,11 +208,15 @@ public class MediaClient {
|
|||
* @return label
|
||||
*/
|
||||
public Single<String> getLabelForDepiction(String entityId, String language) {
|
||||
return mediaDetailInterface.getEntity(entityId, language)
|
||||
return mediaDetailInterface.getEntity(entityId)
|
||||
.map(entities -> {
|
||||
if (isSuccess(entities)) {
|
||||
for (Entity entity : entities.entities().values()) {
|
||||
for (Label label : entity.labels().values()) {
|
||||
final Map<String, Label> languageToLabelMap = entity.labels();
|
||||
if (languageToLabelMap.containsKey(language)) {
|
||||
return languageToLabelMap.get(language).value();
|
||||
}
|
||||
for (Label label : languageToLabelMap.values()) {
|
||||
return label.value();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,11 @@ public interface MediaDetailInterface {
|
|||
|
||||
/**
|
||||
* Gets labels for Depictions using Entity Id from MediaWikiAPI
|
||||
* @param entityId EntityId (Ex: Q81566) of the depict entity
|
||||
*
|
||||
* @param entityId EntityId (Ex: Q81566) of the depict entity
|
||||
* @param language user's locale
|
||||
*/
|
||||
@GET("/w/api.php?format=json&action=wbgetentities&props=labels&languagefallback=1")
|
||||
Observable<Entities> getEntity(@Query("ids") String entityId, @Query("languages") String language);
|
||||
Observable<Entities> getEntity(@Query("ids") String entityId);
|
||||
|
||||
/**
|
||||
* Fetches caption using wikibaseIdentifier
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue