Fix for when there is no user in cache

master
esensar 2017-01-07 17:25:52 +01:00
parent 54c748fb29
commit 5e4e1692e6
1 changed files with 6 additions and 1 deletions

View File

@ -15,7 +15,12 @@ public class UserDAO extends RealmDAO<User> {
}
public User findUserById(Realm realm, int id) {
return realm.copyFromRealm(realm.where(entityClass).equalTo(User.PRIMARY_KEY, id).findFirst());
User user = realm.where(entityClass).equalTo(User.PRIMARY_KEY, id).findFirst();
if(user != null) {
return realm.copyFromRealm(user);
} else {
return null;
}
}
public void deleteById(Realm realm, int id) {