Refactor {languages} binding

This commit is contained in:
Reinhard Pointner 2016-05-10 18:17:16 +08:00
parent 96ecc4db9a
commit 3443fc0de7
1 changed files with 10 additions and 3 deletions

View File

@ -576,9 +576,16 @@ public class MediaBindingBean {
}
@Define("languages")
public Object getSpokenLanguages() {
List<?> languages = infoObject instanceof Movie ? (List<?>) getMetaInfo().getProperty("spokenLanguages") : singletonList(getMetaInfo().getProperty("language"));
return languages.stream().map(it -> new Locale(it.toString()).getDisplayLanguage(Locale.ENGLISH)).collect(toList());
public List<String> getSpokenLanguages() {
if (infoObject instanceof Movie) {
List<Locale> languages = (List<Locale>) getMetaInfo().getProperty("spokenLanguages");
return languages.stream().map(it -> it.getDisplayLanguage(Locale.ENGLISH)).collect(toList());
}
if (infoObject instanceof Episode) {
String language = getSeriesInfo().getLanguage();
return singletonList(new Locale(language).getDisplayLanguage(Locale.ENGLISH));
}
return null;
}
@Define("actors")