use of com.xabber.android.data.message.ChatData in project xabber-android by redsolution.
the class ChatManager method loadChatDataFromRealm.
@Nullable
public ChatData loadChatDataFromRealm(AbstractChat chat) {
String accountJid = chat.getAccount().toString();
String userJid = chat.getUser().toString();
ChatData chatData = null;
Realm realm = RealmManager.getInstance().getNewRealm();
ChatDataRealm realmChat = realm.where(ChatDataRealm.class).equalTo("accountJid", accountJid).equalTo("userJid", userJid).findFirst();
if (realmChat != null) {
NotificationState notificationState;
if (realmChat.getNotificationState() != null) {
notificationState = new NotificationState(realmChat.getNotificationState().getMode(), realmChat.getNotificationState().getTimestamp());
} else
notificationState = new NotificationState(NotificationState.NotificationMode.bydefault, 0);
chatData = new ChatData(realmChat.getSubject(), realmChat.getAccountJid(), realmChat.getUserJid(), realmChat.getUnreadCount(), realmChat.isArchived(), notificationState);
}
realm.close();
return chatData;
}
Aggregations