use of im.actor.core.viewmodel.ConversationVM in project actor-platform by actorapp.
the class ChatFragment method onResume.
@Override
public void onResume() {
super.onResume();
findInputBar().setText(messenger().loadDraft(peer), true);
if (peer.getPeerType() == PeerType.PRIVATE) {
UserVM userVM = users().get(peer.getPeerId());
if (userVM.isBot()) {
ConversationVM conversationVM = messenger().getConversationVM(peer);
bind(conversationVM.getIsEmpty(), conversationVM.getIsLoaded(), (isEmpty, valueModel, isLoaded, valueModel2) -> {
if (isEmpty) {
inputOverlayText.setText(R.string.chat_empty_bot);
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(true);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
} else {
goneView(inputOverlayContainer, false);
showView(inputContainer, false);
}
if (isEmpty && isLoaded) {
showView(emptyContainer, false);
} else {
hideView(emptyContainer, false);
}
});
bind(userVM.getAbout(), (val, valueModel) -> {
if (val == null) {
findEmptyPlaceholder().setText(getString(R.string.chat_empty_bot_about));
} else {
findEmptyPlaceholder().setText(val);
}
});
} else {
bind(userVM.getIsBlocked(), (val, valueModel) -> {
if (val) {
inputOverlayText.setText(R.string.blocked_unblock);
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(true);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
} else {
goneView(inputOverlayContainer, false);
showView(inputContainer, false);
}
});
}
} else if (peer.getPeerType() == PeerType.GROUP) {
GroupVM groupVM = groups().get(peer.getPeerId());
bind(groupVM.isMember(), groupVM.getIsCanWriteMessage(), (isMember, valueModel, canWriteMessage, valueModel2) -> {
if (canWriteMessage) {
goneView(inputOverlayContainer, false);
showView(inputContainer, false);
} else if (isMember) {
if (messenger().isNotificationsEnabled(peer)) {
inputOverlayText.setText(getString(R.string.chat_mute));
} else {
inputOverlayText.setText(getString(R.string.chat_unmute));
}
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(true);
inputOverlayText.setEnabled(true);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
} else if (groupVM.getIsCanJoin().get()) {
inputOverlayText.setText(getString(R.string.join));
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(true);
inputOverlayText.setEnabled(true);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
} else if (groupVM.getIsDeleted().get()) {
inputOverlayText.setText(groupVM.getGroupType() == GroupType.CHANNEL ? R.string.channel_deleted : R.string.group_deleted);
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(false);
inputOverlayText.setEnabled(false);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
} else {
inputOverlayText.setText(R.string.chat_not_member);
inputOverlayText.setTextColor(style.getListActionColor());
inputOverlayText.setClickable(false);
inputOverlayText.setEnabled(false);
showView(inputOverlayContainer, false);
goneView(inputContainer, false);
}
});
}
}
Aggregations