Search in sources :

Example 1 with Dialog

use of im.actor.core.entity.Dialog in project actor-platform by actorapp.

the class DialogsActor method onMessageContentChanged.

@Verified
private Promise<Void> onMessageContentChanged(Peer peer, long rid, AbsContent content) {
    Dialog dialog = dialogs.getValue(peer.getUnuqueId());
    // If message is on top
    if (dialog != null && dialog.getRid() == rid) {
        ContentDescription description = ContentDescription.fromContent(content);
        addOrUpdateItem(new DialogBuilder(dialog).setText(description.getText()).setRelatedUid(description.getRelatedUser()).setMessageType(description.getContentType()).createDialog());
    }
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) ContentDescription(im.actor.core.entity.ContentDescription) DialogBuilder(im.actor.core.entity.DialogBuilder) Verified(im.actor.runtime.annotations.Verified)

Example 2 with Dialog

use of im.actor.core.entity.Dialog in project actor-platform by actorapp.

the class DialogsActor method onGroupChanged.

@Verified
private Promise<Void> onGroupChanged(Group group) {
    Dialog dialog = dialogs.getValue(group.peer().getUnuqueId());
    if (dialog != null) {
        // Ignore if nothing changed
        if (dialog.getDialogTitle().equals(group.getTitle()) && equalsE(dialog.getDialogAvatar(), group.getAvatar())) {
            return Promise.success(null);
        }
        // Update dialog peer info
        Dialog updated = dialog.editPeerInfo(group.getTitle(), group.getAvatar());
        addOrUpdateItem(updated);
        updateSearch(updated);
    }
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) Verified(im.actor.runtime.annotations.Verified)

Example 3 with Dialog

use of im.actor.core.entity.Dialog in project actor-platform by actorapp.

the class BaseDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    BindedDisplayList<Dialog> displayList = messenger().getDialogsDisplayList();
    if (displayList.getListProcessor() == null) {
        displayList.setListProcessor((items, previous) -> {
            for (Dialog d : items) {
                if (d.getSenderId() != 0) {
                    users().get(d.getSenderId());
                }
            }
            return null;
        });
    }
    View res = inflate(inflater, container, R.layout.fragment_dialogs, displayList);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    // Footer
    FrameLayout footer = new FrameLayout(getActivity());
    footer.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(160)));
    footer.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    addFooterView(footer);
    // Header
    View header = new View(getActivity());
    header.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(ActorSDK.sharedActor().style.getDialogsPaddingTopDp())));
    header.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    addHeaderView(header);
    // Empty View
    emptyDialogs = res.findViewById(R.id.emptyDialogs);
    bind(messenger().getAppState().getIsDialogsEmpty(), (val, Value) -> {
        if (val) {
            emptyDialogs.setVisibility(View.VISIBLE);
        } else {
            emptyDialogs.setVisibility(View.GONE);
        }
    });
    ((TextView) res.findViewById(R.id.add_contact_hint_text)).setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    ((TextView) emptyDialogs.findViewById(R.id.empty_dialogs_text)).setTextColor(ActorSDK.sharedActor().style.getMainColor());
    emptyDialogs.findViewById(R.id.empty_dialogs_bg).setBackgroundColor(ActorSDK.sharedActor().style.getMainColor());
    return res;
}
Also used : Dialog(im.actor.core.entity.Dialog) FrameLayout(android.widget.FrameLayout) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 4 with Dialog

use of im.actor.core.entity.Dialog in project actor-platform by actorapp.

the class DialogsActor method onUserChanged.

@Verified
private Promise<Void> onUserChanged(User user) {
    Dialog dialog = dialogs.getValue(user.peer().getUnuqueId());
    if (dialog != null) {
        // Ignore if nothing changed
        if (dialog.getDialogTitle().equals(user.getName()) && equalsE(dialog.getDialogAvatar(), user.getAvatar())) {
            return Promise.success(null);
        }
        // Update dialog peer info
        Dialog updated = dialog.editPeerInfo(user.getName(), user.getAvatar());
        addOrUpdateItem(updated);
        updateSearch(updated);
    }
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) Verified(im.actor.runtime.annotations.Verified)

Example 5 with Dialog

use of im.actor.core.entity.Dialog in project actor-platform by actorapp.

the class DialogsActor method onHistoryLoaded.

@Verified
private Promise<Void> onHistoryLoaded(List<DialogHistory> history) {
    ArrayList<Dialog> updated = new ArrayList<Dialog>();
    for (DialogHistory dialogHistory : history) {
        // Ignore already available dialogs
        if (dialogs.getValue(dialogHistory.getPeer().getUnuqueId()) != null) {
            continue;
        }
        PeerDesc peerDesc = buildPeerDesc(dialogHistory.getPeer());
        if (peerDesc == null) {
            continue;
        }
        ContentDescription description = ContentDescription.fromContent(dialogHistory.getContent());
        DialogBuilder builder = new DialogBuilder().setPeer(dialogHistory.getPeer()).setDialogTitle(peerDesc.getTitle()).setDialogAvatar(peerDesc.getAvatar()).setSortKey(dialogHistory.getSortDate()).setRid(dialogHistory.getRid()).setTime(dialogHistory.getDate()).setMessageType(description.getContentType()).setText(description.getText()).setSenderId(dialogHistory.getSenderId()).setRelatedUid(description.getRelatedUser()).setUnreadCount(dialogHistory.getUnreadCount());
        if (dialogHistory.isRead()) {
            builder.updateKnownReadDate(dialogHistory.getDate());
            builder.updateKnownReceiveDate(dialogHistory.getDate());
        } else if (dialogHistory.isReceived()) {
            builder.updateKnownReceiveDate(dialogHistory.getDate());
        }
        updated.add(builder.createDialog());
    }
    addOrUpdateItems(updated);
    updateSearch(updated);
    notifyState(true);
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) DialogHistory(im.actor.core.modules.messaging.history.entity.DialogHistory) ArrayList(java.util.ArrayList) ContentDescription(im.actor.core.entity.ContentDescription) DialogBuilder(im.actor.core.entity.DialogBuilder) Verified(im.actor.runtime.annotations.Verified)

Aggregations

Dialog (im.actor.core.entity.Dialog)8 Verified (im.actor.runtime.annotations.Verified)5 ContentDescription (im.actor.core.entity.ContentDescription)3 DialogBuilder (im.actor.core.entity.DialogBuilder)3 ArrayList (java.util.ArrayList)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 Contact (im.actor.core.entity.Contact)1 Message (im.actor.core.entity.Message)1 SearchEntity (im.actor.core.entity.SearchEntity)1 Sticker (im.actor.core.entity.Sticker)1 StickerPack (im.actor.core.entity.StickerPack)1 DocumentContent (im.actor.core.entity.content.DocumentContent)1 FileRemoteSource (im.actor.core.entity.content.FileRemoteSource)1 StickerContent (im.actor.core.entity.content.StickerContent)1 JsContact (im.actor.core.js.entity.JsContact)1 JsDialog (im.actor.core.js.entity.JsDialog)1 JsDialogGroup (im.actor.core.js.entity.JsDialogGroup)1