From f9c5cdee6e676afa49d9ae99d060b31e43089563 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 11 Jul 2018 13:20:06 +0200 Subject: [PATCH] fall back to random subject langugae in case there is no english one --- src/main/java/eu/siacs/conversations/xml/Element.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java index 0bbdbcebb..009e56eec 100644 --- a/src/main/java/eu/siacs/conversations/xml/Element.java +++ b/src/main/java/eu/siacs/conversations/xml/Element.java @@ -75,7 +75,7 @@ public class Element { return findInternationalizedChildContent(name, Locale.getDefault().getLanguage()); } - public String findInternationalizedChildContent(String name,@NonNull String language) { + private String findInternationalizedChildContent(String name, @NonNull String language) { HashMap contents = new HashMap<>(); for(Element child : this.children) { if (name.equals(child.getName())) { @@ -91,7 +91,11 @@ public class Element { } } - return contents.get(null); + String value = contents.get(null); + if (value != null) { + return value; + } + return contents.size() > 0 ? contents.values().iterator().next() : null; } public Element findChild(String name, String xmlns) {