attempt to fix some rare crashes

This commit is contained in:
Daniel Gultsch 2019-10-26 13:23:27 +02:00
parent db3ca3f165
commit 2bed0dad12
2 changed files with 7 additions and 3 deletions

View file

@ -335,7 +335,7 @@ public class MucOptions {
} }
public boolean isContactInRoom(Contact contact) { public boolean isContactInRoom(Contact contact) {
return findUserByRealJid(contact.getJid().asBareJid()) != null; return contact != null && findUserByRealJid(contact.getJid().asBareJid()) != null;
} }
public boolean isUserInRoom(Jid jid) { public boolean isUserInRoom(Jid jid) {

View file

@ -1960,9 +1960,13 @@ public class XmppConnectionService extends Service {
* This will find all conferences with the contact as member and also the conference that is the contact (that 'fake' contact is used to store the avatar) * This will find all conferences with the contact as member and also the conference that is the contact (that 'fake' contact is used to store the avatar)
*/ */
public List<Conversation> findAllConferencesWith(Contact contact) { public List<Conversation> findAllConferencesWith(Contact contact) {
ArrayList<Conversation> results = new ArrayList<>(); final ArrayList<Conversation> results = new ArrayList<>();
for (final Conversation c : conversations) { for (final Conversation c : conversations) {
if (c.getMode() == Conversation.MODE_MULTI && (c.getJid().asBareJid().equals(contact.getJid().asBareJid()) || c.getMucOptions().isContactInRoom(contact))) { if (c.getMode() != Conversation.MODE_MULTI) {
continue;
}
final MucOptions mucOptions = c.getMucOptions();
if (c.getJid().asBareJid().equals(contact.getJid().asBareJid()) || (mucOptions != null && mucOptions.isContactInRoom(contact))) {
results.add(c); results.add(c);
} }
} }