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);
}
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);
}
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;
}
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);
}
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);
}
Aggregations