Skip to content

Commit

Permalink
using if conditions to check
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratham2305 committed Feb 27, 2021
1 parent 5a4a094 commit 23e2784
Showing 1 changed file with 12 additions and 6 deletions.
Expand Up @@ -64,7 +64,6 @@
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.nearby.Label;
import fr.free.nrw.commons.settings.Prefs;
import fr.free.nrw.commons.ui.widget.HtmlTextView;
import fr.free.nrw.commons.utils.ViewUtilWrapper;
import io.reactivex.Single;
Expand Down Expand Up @@ -619,17 +618,24 @@ private void buildDepictionList(List<IdAndCaptions> idAndCaptions) {
String locale = Locale.getDefault().getLanguage();
for (IdAndCaptions idAndCaption : idAndCaptions) {
depictionContainer.addView(buildDepictLabel(
//Check if the Depiction Caption is available in user's locale if not then check for english, else show any available.
idAndCaption.getCaptions().get(locale) != null
? idAndCaption.getCaptions().get(locale)
: ((idAndCaption.getCaptions().get("en") != null) ? idAndCaption.getCaptions().get("en")
: idAndCaption.getCaptions().values().iterator().next()),
getDepictionCaption(idAndCaption, locale),
idAndCaption.getId(),
depictionContainer
));
}
}

private String getDepictionCaption(IdAndCaptions idAndCaption, String locale) {
//Check if the Depiction Caption is available in user's locale if not then check for english, else show any available.
if(idAndCaption.getCaptions().get(locale) != null) {
return idAndCaption.getCaptions().get(locale);
}
if(idAndCaption.getCaptions().get("en") != null) {
return idAndCaption.getCaptions().get("en");
}
return idAndCaption.getCaptions().values().iterator().next();
}

@OnClick(R.id.mediaDetailLicense)
public void onMediaDetailLicenceClicked(){
String url = media.getLicenseUrl();
Expand Down

0 comments on commit 23e2784

Please sign in to comment.