use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.
the class ForwardMessageAction method forwardOneByOne.
private void forwardOneByOne(List<UiMessage> messages) {
ArrayList<Message> msgs = messages.stream().map(uiMessage -> uiMessage.message).collect(Collectors.toCollection(ArrayList::new));
Intent intent = new Intent(fragment.getContext(), ForwardActivity.class);
intent.putExtra("messages", msgs);
fragment.startActivity(intent);
}
use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.
the class FavAudioContentViewHolder method playAudio.
@OnClick(R2.id.audioContentLayout)
void playAudio() {
Message message = favoriteItem.toMessage();
uiMessage = new UiMessage(message);
MessageViewModel messageViewModel = ViewModelProviders.of(fragment).get(MessageViewModel.class);
File file = messageViewModel.mediaMessageContentFile(message);
if (file == null) {
return;
}
if (file.exists()) {
messageViewModel.playAudioMessage(uiMessage);
} else {
if (uiMessage.isDownloading) {
return;
}
messageViewModel.downloadMedia(uiMessage, file);
}
}
use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.
the class ConversationViewHolder method onBind.
public void onBind(ConversationInfo conversationInfo) {
secretChatIndicator.setVisibility(View.GONE);
onBindConversationInfo(conversationInfo);
timeTextView.setText(TimeUtils.getMsgFormatTime(conversationInfo.timestamp));
silentImageView.setVisibility(conversationInfo.isSilent ? View.VISIBLE : View.GONE);
statusImageView.setVisibility(View.GONE);
itemView.setBackgroundResource(conversationInfo.isTop ? R.drawable.selector_stick_top_item : R.drawable.selector_common_item);
redDotView.setVisibility(View.GONE);
if (conversationInfo.isSilent) {
if (conversationInfo.unreadCount.unread > 0) {
// 显示红点
unreadCountTextView.setText("");
unreadCountTextView.setVisibility(View.GONE);
redDotView.setVisibility(View.VISIBLE);
} else {
unreadCountTextView.setVisibility(View.GONE);
}
} else {
if (conversationInfo.unreadCount.unread > 0) {
unreadCountTextView.setVisibility(View.VISIBLE);
unreadCountTextView.setText(conversationInfo.unreadCount.unread > 99 ? "99+" : conversationInfo.unreadCount.unread + "");
} else {
unreadCountTextView.setVisibility(View.GONE);
}
}
Draft draft = Draft.fromDraftJson(conversationInfo.draft);
if (draft != null) {
String draftString = draft.getContent() != null ? draft.getContent() : "[草稿]";
MoonUtils.identifyFaceExpression(fragment.getActivity(), contentTextView, draft.getContent(), ImageSpan.ALIGN_BOTTOM);
setViewVisibility(R.id.promptTextView, View.VISIBLE);
setViewVisibility(R.id.contentTextView, View.VISIBLE);
} else {
if (conversationInfo.unreadCount.unreadMentionAll > 0 || conversationInfo.unreadCount.unreadMention > 0) {
promptTextView.setText("[有人@我]");
promptTextView.setVisibility(View.VISIBLE);
} else {
promptTextView.setVisibility(View.GONE);
}
setViewVisibility(R.id.contentTextView, View.VISIBLE);
if (conversationInfo.lastMessage != null && conversationInfo.lastMessage.content != null) {
String content = "";
Message lastMessage = conversationInfo.lastMessage;
// the message maybe invalid
try {
if (conversationInfo.conversation.type == Conversation.ConversationType.Group && lastMessage.direction == MessageDirection.Receive && !(lastMessage.content instanceof NotificationMessageContent)) {
GroupViewModel groupViewModel = ViewModelProviders.of(fragment).get(GroupViewModel.class);
String senderDisplayName = groupViewModel.getGroupMemberDisplayName(conversationInfo.conversation.target, conversationInfo.lastMessage.sender);
content = senderDisplayName + ":" + lastMessage.digest();
} else {
content = lastMessage.digest();
}
} catch (Exception e) {
e.printStackTrace();
}
content = WfcTextUtils.htmlToText(content);
MoonUtils.identifyFaceExpression(fragment.getActivity(), contentTextView, content, ImageSpan.ALIGN_BOTTOM);
switch(lastMessage.status) {
case Sending:
statusImageView.setVisibility(View.VISIBLE);
// TODO update sending image resource
statusImageView.setImageResource(R.mipmap.ic_sending);
break;
case Send_Failure:
statusImageView.setVisibility(View.VISIBLE);
statusImageView.setImageResource(R.mipmap.img_error);
break;
default:
statusImageView.setVisibility(View.GONE);
break;
}
} else {
contentTextView.setText("");
}
}
}
use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.
the class BaseConferenceFragment method onReceiveMessage.
@Override
public void onReceiveMessage(List<Message> messages, boolean hasMore) {
if (AVEngineKit.Instance().getCurrentSession() != null && AVEngineKit.Instance().getCurrentSession().isConference()) {
for (Message msg : messages) {
if (msg.content instanceof ConferenceChangeModeContent) {
ConferenceChangeModeContent content = (ConferenceChangeModeContent) msg.content;
onChangeModeRequest(content.getCallId(), content.isAudience());
}
}
}
}
use of cn.wildfirechat.message.Message in project android-chat by wildfirechat.
the class ConferenceInviteActivity method invite.
private void invite(String targetName, String targetPortrait, Conversation targetConversation) {
ForwardPromptView view = new ForwardPromptView(this);
view.bind(targetName, targetPortrait, "会议邀请");
MaterialDialog dialog = new MaterialDialog.Builder(this).customView(view, false).negativeText("取消").positiveText("发送").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Message extraMsg = null;
if (!TextUtils.isEmpty(view.getEditText())) {
TextMessageContent content = new TextMessageContent(view.getEditText());
extraMsg = new Message();
extraMsg.content = content;
}
messageViewModel.sendMessage(targetConversation, inviteMessage);
Toast.makeText(ConferenceInviteActivity.this, "邀请成功", Toast.LENGTH_SHORT).show();
finish();
// .observe(ConferenceInviteActivity.this, new Observer<OperateResult<Integer>>() {
// @Override
// public void onChanged(@Nullable OperateResult<Integer> integerOperateResult) {
// if (integerOperateResult.isSuccess()) {
// Toast.makeText(ConferenceInviteActivity.this, "邀请成功", Toast.LENGTH_SHORT).show();
// finish();
// } else {
// Toast.makeText(ConferenceInviteActivity.this, "邀请失败" + integerOperateResult.getErrorCode(), Toast.LENGTH_SHORT).show();
// }
// }
// });
}
}).build();
dialog.show();
}
Aggregations