don't fail on missing jid in bookmarks

This commit is contained in:
Daniel Gultsch 2016-06-16 20:38:35 +02:00
parent b92b3863b9
commit f91d16cbe7

View file

@ -56,7 +56,9 @@ public class Bookmark extends Element implements ListItem {
&& !getBookmarkName().trim().isEmpty()) { && !getBookmarkName().trim().isEmpty()) {
return getBookmarkName().trim(); return getBookmarkName().trim();
} else { } else {
return this.getJid().getLocalpart(); Jid jid = this.getJid();
String name = jid != null ? jid.getLocalpart() : getAttribute("jid");
return name != null ? name : "";
} }
} }
@ -66,7 +68,7 @@ public class Bookmark extends Element implements ListItem {
if (jid != null) { if (jid != null) {
return jid.toString(); return jid.toString();
} else { } else {
return null; return getAttribute("jid"); //fallback if jid wasn't parsable
} }
} }
@ -77,7 +79,7 @@ public class Bookmark extends Element implements ListItem {
@Override @Override
public List<Tag> getTags(Context context) { public List<Tag> getTags(Context context) {
ArrayList<Tag> tags = new ArrayList<Tag>(); ArrayList<Tag> tags = new ArrayList<>();
for (Element element : getChildren()) { for (Element element : getChildren()) {
if (element.getName().equals("group") && element.getContent() != null) { if (element.getName().equals("group") && element.getContent() != null) {
String group = element.getContent(); String group = element.getContent();