use of com.xabber.android.data.database.realm.PatreonGoalRealm in project xabber-android by redsolution.
the class PatreonManager method patreonRealmToDTO.
private XabberComClient.Patreon patreonRealmToDTO(PatreonRealm realmItem) {
List<XabberComClient.PatreonGoal> patreonGoals = new ArrayList<>();
for (PatreonGoalRealm patreonGoalRealm : realmItem.getGoals()) {
XabberComClient.PatreonGoal patreonGoal = new XabberComClient.PatreonGoal(patreonGoalRealm.getTitle(), patreonGoalRealm.getGoal());
patreonGoals.add(patreonGoal);
}
return new XabberComClient.Patreon(realmItem.getString(), realmItem.getPledged(), patreonGoals);
}
use of com.xabber.android.data.database.realm.PatreonGoalRealm in project xabber-android by redsolution.
the class PatreonManager method savePatreonToRealm.
public Single<XabberComClient.Patreon> savePatreonToRealm(XabberComClient.Patreon patreon) {
RealmList<PatreonGoalRealm> patreonGoals = new RealmList<>();
for (XabberComClient.PatreonGoal patreonGoal : patreon.getGoals()) {
PatreonGoalRealm patreonGoalRealm = new PatreonGoalRealm();
patreonGoalRealm.setGoal(patreonGoal.getGoal());
patreonGoalRealm.setTitle(patreonGoal.getTitle());
patreonGoals.add(patreonGoalRealm);
}
PatreonRealm patreonRealm = new PatreonRealm("1");
patreonRealm.setPledged(patreon.getPledged());
patreonRealm.setString(patreon.getString());
patreonRealm.setGoals(patreonGoals);
// TODO: 13.03.18 ANR - WRITE
final long startTime = System.currentTimeMillis();
Realm realm = RealmManager.getInstance().getNewRealm();
realm.beginTransaction();
PatreonRealm resultRealm = realm.copyToRealmOrUpdate(patreonRealm);
realm.commitTransaction();
XabberComClient.Patreon result = patreonRealmToDTO(resultRealm);
realm.close();
LogManager.d("REALM", Thread.currentThread().getName() + " save patreon data: " + (System.currentTimeMillis() - startTime));
Log.d(LOG_TAG, "Patreon was saved to Realm");
return Single.just(result);
}
Aggregations