Search in sources :

Example 1 with ArrayListDialogSmall

use of im.actor.core.viewmodel.generics.ArrayListDialogSmall in project actor-platform by actorapp.

the class RouterActor method notifyActiveDialogsVM.

private void notifyActiveDialogsVM() {
    int counter = 0;
    ArrayList<DialogGroup> groups = new ArrayList<>();
    for (ActiveDialogGroup i : activeDialogStorage.getGroups()) {
        ArrayListDialogSmall dialogSmalls = new ArrayListDialogSmall();
        for (Peer p : i.getPeers()) {
            String title;
            Avatar avatar;
            if (p.getPeerType() == PeerType.GROUP) {
                Group group = getGroup(p.getPeerId());
                title = group.getTitle();
                avatar = group.getAvatar();
            } else if (p.getPeerType() == PeerType.PRIVATE) {
                User user = getUser(p.getPeerId());
                title = user.getName();
                avatar = user.getAvatar();
            } else {
                continue;
            }
            int unreadCount = conversationStates.getValue(p.getUnuqueId()).getUnreadCount();
            counter += unreadCount;
            dialogSmalls.add(new DialogSmall(p, title, avatar, unreadCount));
        }
        groups.add(new DialogGroup(i.getTitle(), i.getKey(), dialogSmalls));
    }
    context().getMessagesModule().getDialogGroupsVM().getGroupsValueModel().change(groups);
    context().getConductor().getGlobalStateVM().onGlobalCounterChanged(counter);
}
Also used : ApiDialogGroup(im.actor.core.api.ApiDialogGroup) Group(im.actor.core.entity.Group) DialogGroup(im.actor.core.viewmodel.DialogGroup) ActiveDialogGroup(im.actor.core.modules.messaging.router.entity.ActiveDialogGroup) ArrayListDialogSmall(im.actor.core.viewmodel.generics.ArrayListDialogSmall) User(im.actor.core.entity.User) ApiDialogGroup(im.actor.core.api.ApiDialogGroup) DialogGroup(im.actor.core.viewmodel.DialogGroup) ActiveDialogGroup(im.actor.core.modules.messaging.router.entity.ActiveDialogGroup) Peer(im.actor.core.entity.Peer) ArrayList(java.util.ArrayList) ActiveDialogGroup(im.actor.core.modules.messaging.router.entity.ActiveDialogGroup) DialogSmall(im.actor.core.viewmodel.DialogSmall) ArrayListDialogSmall(im.actor.core.viewmodel.generics.ArrayListDialogSmall) Avatar(im.actor.core.entity.Avatar)

Aggregations

ApiDialogGroup (im.actor.core.api.ApiDialogGroup)1 Avatar (im.actor.core.entity.Avatar)1 Group (im.actor.core.entity.Group)1 Peer (im.actor.core.entity.Peer)1 User (im.actor.core.entity.User)1 ActiveDialogGroup (im.actor.core.modules.messaging.router.entity.ActiveDialogGroup)1 DialogGroup (im.actor.core.viewmodel.DialogGroup)1 DialogSmall (im.actor.core.viewmodel.DialogSmall)1 ArrayListDialogSmall (im.actor.core.viewmodel.generics.ArrayListDialogSmall)1 ArrayList (java.util.ArrayList)1