本文整理汇总了Java中io.rong.imlib.model.MessageContent类的典型用法代码示例。如果您正苦于以下问题:Java MessageContent类的具体用法?Java MessageContent怎么用?Java MessageContent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageContent类属于io.rong.imlib.model包,在下文中一共展示了MessageContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConversationClick
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
@Override
public boolean onConversationClick(Context context, View view, UIConversation uiConversation) {
MessageContent messageContent = uiConversation.getMessageContent();
if (messageContent instanceof ContactNotificationMessage) {
ContactNotificationMessage contactNotificationMessage = (ContactNotificationMessage) messageContent;
if (contactNotificationMessage.getOperation().equals("AcceptResponse")) {
// 被加方同意请求后
if (contactNotificationMessage.getExtra() != null) {
ContactNotificationMessageData bean = null;
try {
bean = JsonMananger.jsonToBean(contactNotificationMessage.getExtra(), ContactNotificationMessageData.class);
} catch (Exception e) {
e.printStackTrace();
}
RongIM.getInstance().startPrivateChat(context, uiConversation.getConversationSenderId(), bean.getSourceUserNickname());
}
} else {
context.startActivity(new Intent(context, NewFriendListActivity.class));
}
return true;
}
return false;
}
示例2: getColoredChattingRecord
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public SpannableStringBuilder getColoredChattingRecord(String filterStr, MessageContent messageContent) {
SpannableStringBuilder messageText = new SpannableStringBuilder();
if (messageContent instanceof TextMessage) {
TextMessage textMessage = (TextMessage) messageContent;
String textMessageContent = textMessage.getContent();
messageText = getOmitColored(filterStr, textMessageContent, 0);
}
if (messageContent instanceof RichContentMessage) {
RichContentMessage richContentMessage = (RichContentMessage) messageContent;
String messageTitle = richContentMessage.getTitle();
messageText = getOmitColored(filterStr, messageTitle, 1);
if (messageText.length() == 0) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("[链接] ");
spannableStringBuilder.append(messageTitle);
messageText = spannableStringBuilder;
}
}
if (messageContent instanceof FileMessage) {
FileMessage fileMessage = (FileMessage) messageContent;
String fileName = fileMessage.getName();
messageText = getOmitColored(filterStr, fileName, 2);
}
return messageText;
}
示例3: sendShareMessage
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
private void sendShareMessage(Conversation.ConversationType conversationType, String targetId, MessageContent content) {
RongIM.getInstance().sendMessage(conversationType, targetId, content, null, null, new RongIMClient.SendMessageCallback() {
@Override
public void onError(Integer messageId, RongIMClient.ErrorCode e) {
NLog.e("share", e.getValue());
LoadDialog.dismiss(mContext);
NToast.shortToast(mContext, "分享失败");
}
@Override
public void onSuccess(Integer integer) {
LoadDialog.dismiss(mContext);
NToast.shortToast(mContext, "分享成功");
}
});
}
示例4: onConversationClick
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
@Override
public boolean onConversationClick(Context context, View view, UIConversation uiConversation) {
MessageContent messageContent = uiConversation.getMessageContent();
if (messageContent instanceof ContactNotificationMessage) {
ContactNotificationMessage contactNotificationMessage = (ContactNotificationMessage) messageContent;
if (contactNotificationMessage.getOperation().equals("AcceptResponse")) {
// 被加方同意请求后
if (contactNotificationMessage.getExtra() != null) {
ContactNotificationMessageData bean = null;
try {
bean = JsonMananger.jsonToBean(contactNotificationMessage.getExtra(), ContactNotificationMessageData.class);
} catch (Exception e) {
e.printStackTrace();
}
RongIM.getInstance().startPrivateChat(context, uiConversation.getConversationSenderId(), bean.getSourceUserNickname());
}
} else {
context.startActivity(new Intent(context, NewFriendListActivity.class));
}
return true;
}
return false;
}
示例5: getMessageLoadToService
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public static String getMessageLoadToService(MessageContent messageContent) {
String content = "";
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
content = filterEmoji(textMessage.getContent());
} else if (messageContent instanceof LocationMessage) {//
LocationMessage location = (LocationMessage) messageContent;
DecimalFormat df = new DecimalFormat("#.00");
content = PlatformUtil.getInstance().getString(R.string.send_location, location.getPoi(),
df.format(location.getLat()), df.format(location.getLng()));
} else if (messageContent instanceof VoiceMessage) {//
VoiceMessage voiceMessage = (VoiceMessage) messageContent;
content = PlatformUtil.getInstance().getString(R.string.send_voice);
}
return content;
}
示例6: onConversationClick
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
/**
* 点击会话列表 item 后执行。
*
* @param context 上下文。
* @param view 触发点击的 View。
* @param conversation 会话条目。
* @return 返回 true 不再执行融云 SDK 逻辑,返回 false 先执行融云 SDK 逻辑再执行该方法。
*/
@Override
public boolean onConversationClick(Context context, View view, UIConversation conversation) {
MessageContent messageContent = conversation.getMessageContent();
Log.e(TAG, "--------onConversationClick-------");
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
textMessage.getExtra();
} else if (messageContent instanceof ContactNotificationMessage) {
Log.e(TAG, "---onConversationClick--ContactNotificationMessage-");
context.startActivity(new Intent(context, NewFriendListActivity.class));
return true;
}
return false;
}
示例7: setOnClick
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
private void setOnClick(LQRViewHolderForRecyclerView helper, Message item, int position) {
helper.getView(R.id.llError).setOnClickListener(v ->
RongIMClient.getInstance().deleteMessages(new int[]{item.getMessageId()}, new RongIMClient.ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean aBoolean) {
mData.remove(position);
mPresenter.setAdapter();
MessageContent content = item.getContent();
if (content instanceof TextMessage) {
mPresenter.sendTextMsg(((TextMessage) content).getContent());
} else if (content instanceof ImageMessage) {
mPresenter.sendImgMsg(((ImageMessage) content).getThumUri(), ((ImageMessage) content).getLocalUri());
} else if (content instanceof FileMessage) {
mPresenter.sendFileMsg(new File(((FileMessage) content).getLocalPath().getPath()));
} else if (content instanceof VoiceMessage) {
VoiceMessage voiceMessage = (VoiceMessage) content;
mPresenter.sendAudioFile(voiceMessage.getUri(), voiceMessage.getDuration());
}
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
}
})
);
helper.getView(R.id.ivAvatar).setOnClickListener(v -> {
UserInfo userInfo = DBManager.getInstance().getUserInfo(item.getSenderUserId());
if (userInfo != null) {
Intent intent = new Intent(mContext, UserInfoActivity.class);
intent.putExtra("userInfo", userInfo);
((SessionActivity) mContext).jumpToActivity(intent);
}
});
}
示例8: getItemViewType
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
Message msg = mData.get(position);
boolean isSend = msg.getMessageDirection() == Message.MessageDirection.SEND ? true : false;
MessageContent msgContent = msg.getContent();
if (msgContent instanceof TextMessage) {
return isSend ? SEND_TEXT : RECEIVE_TEXT;
}
if (msgContent instanceof ImageMessage) {
return isSend ? SEND_IMAGE : RECEIVE_IMAGE;
}
if (msgContent instanceof FileMessage) {
FileMessage fileMessage = (FileMessage) msgContent;
if (MediaFileUtils.isImageFileType(fileMessage.getName())) {
return isSend ? SEND_STICKER : RECEIVE_STICKER;
} else if (MediaFileUtils.isVideoFileType(fileMessage.getName())) {
return isSend ? SEND_VIDEO : RECEIVE_VIDEO;
}
}
if (msgContent instanceof LocationMessage) {
return isSend ? SEND_LOCATION : RECEIVE_LOCATION;
}
if (msgContent instanceof GroupNotificationMessage) {
return RECEIVE_NOTIFICATION;
}
if (msgContent instanceof VoiceMessage) {
return isSend ? SEND_VOICE : RECEIVE_VOICE;
}
if (msgContent instanceof RedPacketMessage) {
return isSend ? SEND_RED_PACKET : RECEIVE_RED_PACKET;
}
if (msgContent instanceof RecallNotificationMessage) {
return RECALL_NOTIFICATION;
}
return UNDEFINE_MSG;
}
示例9: getMessageContent
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public static String getMessageContent(MessageContent messageContent) {
String content = "";
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
content = textMessage.getContent();
} else if (messageContent instanceof ImageMessage) {//图片消息
ImageMessage imageMessage = (ImageMessage) messageContent;
content = PlatformUtil.getInstance().getString(R.string.im_default_message_image);
} else if (messageContent instanceof VoiceMessage) {//语音消息
VoiceMessage voiceMessage = (VoiceMessage) messageContent;
content = PlatformUtil.getInstance().getString(R.string.im_default_message_voice);
} else if (messageContent instanceof RichContentMessage) {//图文消息
RichContentMessage richContentMessage = (RichContentMessage) messageContent;
content = PlatformUtil.getInstance().getString(R.string.im_default_message_rich_text);
} else if (messageContent instanceof LocationMessage) {//图文消息
LocationMessage location = (LocationMessage) messageContent;
content = PlatformUtil.getInstance().getString(R.string.im_default_message_location_with_string_in, location.getPoi());
} else if (messageContent instanceof InformationNotificationMessage) {//小灰条消息
InformationNotificationMessage informationNotificationMessage = (InformationNotificationMessage) messageContent;
LogHelper.e(TAG, "onReceived-informationNotificationMessage:" + informationNotificationMessage.getMessage());
content = PlatformUtil.getInstance().getString(R.string.im_default_message_notificataion);
} else {
if (messageContent == null) {
content = PlatformUtil.getInstance().getString(R.string.send_message_with_name_below, "");
} else {
content = null;
}
LogHelper.e("omg", " receive push message other" + messageContent);
// content = "[通知]";
}
return content;
}
示例10: translateMessageContent
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public static TranslatedMessageContent translateMessageContent(MessageContent msgContent) {
TranslatedMessageContent content = null;
if (msgContent == null)
return null;
if (msgContent instanceof TextMessage) {
content = new TranslatedTextMessage(msgContent);
} else if (msgContent instanceof ImageMessage) {
content = new TranslatedImageMessage(msgContent);
} else if (msgContent instanceof VoiceMessage) {
content = new TranslatedVoiceMessage(msgContent);
} else if (msgContent instanceof RichContentMessage) {
content = new TranslatedRichContentMessage(msgContent);
} else if (msgContent instanceof CommandNotificationMessage) {
content = new TranslatedCommandNotificationMessage(msgContent);
} else if (msgContent instanceof LocationMessage) {
content = new TranslatedLocationMessage(msgContent);
} else if (msgContent instanceof InformationNotificationMessage) {
content = new TranslatedInformationNtfMessage(msgContent);
} else if (msgContent instanceof DiscussionNotificationMessage) {
content = new TranslatedDiscussionNtfMessage(msgContent);
} else if (msgContent instanceof CommandMessage) {
content = new TranslatedCommandMessage(msgContent);
} else if (msgContent instanceof ContactNotificationMessage) {
content = new TranslatedContactNtfMessage(msgContent);
} else if (msgContent instanceof ProfileNotificationMessage) {
content = new TranslatedProfileNtfMessage(msgContent);
} else if (msgContent instanceof GroupNotificationMessage) {
content = new TranslatedGrpNtfMessage(msgContent);
}
return content;
}
示例11: TranslatedContactNtfMessage
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public TranslatedContactNtfMessage(MessageContent content) {
ContactNotificationMessage msg = (ContactNotificationMessage)content;
operation = msg.getOperation() == null ? "" : msg.getOperation();
sourceUserId = msg.getSourceUserId() == null ? "" : msg.getSourceUserId();
targetUserId = msg.getTargetUserId() == null ? "" : msg.getTargetUserId();
message = msg.getMessage() == null ? "" : msg.getMessage();
extra = msg.getExtra() == null ? "" : msg.getExtra();
}
示例12: TranslatedGrpNtfMessage
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public TranslatedGrpNtfMessage(MessageContent content) {
GroupNotificationMessage msg = (GroupNotificationMessage)content;
operation = msg.getOperation() == null ? "" : msg.getOperation();
operatorUserId = msg.getOperatorUserId() == null ? "" : msg.getOperatorUserId();
data = msg.getData() == null ? "" : msg.getData();
message = msg.getMessage() == null ? "" : msg.getMessage();
extra = msg.getExtra() == null ? "" : msg.getExtra();
}
示例13: TranslatedRichContentMessage
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public TranslatedRichContentMessage(MessageContent content) {
RichContentMessage richContentMessage = (RichContentMessage)content;
this.extra = richContentMessage.getExtra() == null ? "" : richContentMessage.getExtra();
this.title = richContentMessage.getTitle() == null ? "" : richContentMessage.getTitle();
this.description = richContentMessage.getContent() == null ? "" : richContentMessage.getContent();
this.imageUrl = richContentMessage.getImgUrl() == null ? "" : richContentMessage.getImgUrl();
this.url = richContentMessage.getUrl() == null ? "" : richContentMessage.getUrl();
}
示例14: TranslatedImageMessage
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public TranslatedImageMessage(MessageContent content) {
ImageMessage imageMessage = (ImageMessage) content;
this.imageUrl = imageMessage.getRemoteUri() != null ?
imageMessage.getRemoteUri().toString() :
(imageMessage.getLocalUri() != null ? imageMessage.getLocalUri().getPath() : "");
this.thumbPath = imageMessage.getThumUri() != null ? imageMessage.getThumUri().getPath() : "";
this.extra = imageMessage.getExtra() == null ? "" : imageMessage.getExtra();
}
示例15: TranslatedConversation
import io.rong.imlib.model.MessageContent; //导入依赖的package包/类
public TranslatedConversation(Conversation conversation) {
this.conversationTitle = conversation.getConversationTitle() == null ? "" : conversation.getConversationTitle();
this.conversationType = conversation.getConversationType();
this.draft = conversation.getDraft() == null ? "" : conversation.getDraft();
this.targetId = conversation.getTargetId() == null ? "" : conversation.getTargetId();
this.sentStatus = conversation.getSentStatus();
this.objectName = conversation.getObjectName();
int flag = conversation.getReceivedStatus().getFlag();
if (flag == 0)
this.receivedStatus = "UNREAD";
else if (flag == 1)
this.receivedStatus = "READ";
else if (flag == 3 || flag == 2)
this.receivedStatus = "LISTENED";
else if (flag == 4)
this.receivedStatus = "DOWNLOADED";
else
this.receivedStatus = "READ";
this.senderUserId = conversation.getSenderUserId() == null ? "" : conversation.getSenderUserId();
this.unreadMessageCount = conversation.getUnreadMessageCount();
this.receivedTime = conversation.getReceivedTime();
this.sentTime = conversation.getSentTime();
this.isTop = conversation.isTop();
this.latestMessageId = conversation.getLatestMessageId();
MessageContent msgContent = conversation.getLatestMessage();
TranslatedMessageContent tc = TranslatedMessage.translateMessageContent(msgContent);
this.latestMessage = (tc == null ? new TranslatedMessageContent() : tc);
}