use of com.xabber.android.data.database.realm.CrowdfundingMessage in project xabber-android by redsolution.
the class CrowdfundingManager method removeDelay.
public void removeDelay(int delay) {
Realm realm = RealmManager.getInstance().getNewRealm();
RealmResults<CrowdfundingMessage> messages = getMessagesWithDelay(delay);
realm.beginTransaction();
for (CrowdfundingMessage message : messages) {
// remove delay and update received time
message.setDelay(0);
message.setTimestamp(getCurrentTime());
}
realm.commitTransaction();
realm.close();
}
use of com.xabber.android.data.database.realm.CrowdfundingMessage in project xabber-android by redsolution.
the class CrowdfundingManager method markMessagesAsRead.
public void markMessagesAsRead(String[] ids) {
if (ids.length == 0)
return;
Realm realm = RealmManager.getInstance().getNewRealm();
RealmResults<CrowdfundingMessage> messages = realm.where(CrowdfundingMessage.class).equalTo(CrowdfundingMessage.Fields.READ, false).in(CrowdfundingMessage.Fields.ID, ids).findAll();
realm.beginTransaction();
for (CrowdfundingMessage message : messages) {
message.setRead(true);
}
realm.commitTransaction();
}
use of com.xabber.android.data.database.realm.CrowdfundingMessage in project xabber-android by redsolution.
the class CrowdfundingManager method saveCrowdfundingMessageToRealm.
public Single<List<CrowdfundingMessage>> saveCrowdfundingMessageToRealm(List<CrowdfundingClient.Message> messages) {
RealmList<CrowdfundingMessage> realmMessages = new RealmList<>();
for (CrowdfundingClient.Message message : messages) {
realmMessages.add(messageToRealm(message));
}
Realm realm = RealmManager.getInstance().getNewRealm();
realm.beginTransaction();
List<CrowdfundingMessage> result = realm.copyToRealmOrUpdate(realmMessages);
realm.commitTransaction();
return Single.just(result);
}
use of com.xabber.android.data.database.realm.CrowdfundingMessage in project xabber-android by redsolution.
the class CrowdfundingManager method getLastMessageFromRealm.
public CrowdfundingMessage getLastMessageFromRealm() {
Realm realm = RealmManager.getInstance().getNewRealm();
RealmResults<CrowdfundingMessage> messages = realm.where(CrowdfundingMessage.class).findAllSorted(CrowdfundingMessage.Fields.TIMESTAMP);
if (messages != null && !messages.isEmpty())
return messages.last();
else
return null;
}
use of com.xabber.android.data.database.realm.CrowdfundingMessage in project xabber-android by redsolution.
the class CrowdfundingManager method removeAllMessages.
private void removeAllMessages() {
Realm realm = RealmManager.getInstance().getNewRealm();
RealmResults<CrowdfundingMessage> messages = realm.where(CrowdfundingMessage.class).findAll();
realm.beginTransaction();
for (CrowdfundingMessage message : messages) message.deleteFromRealm();
realm.commitTransaction();
}
Aggregations