Search in sources :

Example 11 with CrowdfundingMessage

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();
}
Also used : Realm(io.realm.Realm) CrowdfundingMessage(com.xabber.android.data.database.realm.CrowdfundingMessage)

Example 12 with CrowdfundingMessage

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();
}
Also used : Realm(io.realm.Realm) CrowdfundingMessage(com.xabber.android.data.database.realm.CrowdfundingMessage)

Example 13 with CrowdfundingMessage

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);
}
Also used : RealmList(io.realm.RealmList) Realm(io.realm.Realm) CrowdfundingMessage(com.xabber.android.data.database.realm.CrowdfundingMessage)

Example 14 with CrowdfundingMessage

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;
}
Also used : Realm(io.realm.Realm) CrowdfundingMessage(com.xabber.android.data.database.realm.CrowdfundingMessage)

Example 15 with CrowdfundingMessage

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();
}
Also used : Realm(io.realm.Realm) CrowdfundingMessage(com.xabber.android.data.database.realm.CrowdfundingMessage)

Aggregations

CrowdfundingMessage (com.xabber.android.data.database.realm.CrowdfundingMessage)16 Realm (io.realm.Realm)7 AbstractChat (com.xabber.android.data.message.AbstractChat)3 NewMessageEvent (com.xabber.android.data.message.NewMessageEvent)3 CrowdfundingContact (com.xabber.android.data.roster.CrowdfundingContact)3 RealmList (io.realm.RealmList)3 ArrayList (java.util.ArrayList)3 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)2 CrowdfundingChat (com.xabber.android.data.message.CrowdfundingChat)2 AbstractContact (com.xabber.android.data.roster.AbstractContact)2 GroupConfiguration (com.xabber.android.ui.adapter.contactlist.GroupConfiguration)2 List (java.util.List)2 Action1 (rx.functions.Action1)2 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 DrawableImageViewTarget (com.bumptech.glide.request.target.DrawableImageViewTarget)1