avoid very rare npe

This commit is contained in:
Daniel Gultsch 2015-07-03 21:32:46 +02:00
parent 1c86098f3b
commit d30fb6f0a1
2 changed files with 4 additions and 2 deletions

View File

@ -74,6 +74,9 @@ public class Roster {
} }
public void initContact(final Contact contact) { public void initContact(final Contact contact) {
if (contact == null) {
return;
}
contact.setAccount(account); contact.setAccount(account);
contact.setOption(Contact.Options.IN_ROSTER); contact.setOption(Contact.Options.IN_ROSTER);
synchronized (this.contacts) { synchronized (this.contacts) {

View File

@ -386,8 +386,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor; Cursor cursor;
String args[] = { roster.getAccount().getUuid() }; String args[] = { roster.getAccount().getUuid() };
cursor = db.query(Contact.TABLENAME, null, Contact.ACCOUNT + "=?", cursor = db.query(Contact.TABLENAME, null, Contact.ACCOUNT + "=?", args, null, null, null);
args, null, null, null);
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
roster.initContact(Contact.fromCursor(cursor)); roster.initContact(Contact.fromCursor(cursor));
} }