本文整理汇总了Java中io.rong.message.TextMessage类的典型用法代码示例。如果您正苦于以下问题:Java TextMessage类的具体用法?Java TextMessage怎么用?Java TextMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextMessage类属于io.rong.message包,在下文中一共展示了TextMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColoredChattingRecord
import io.rong.message.TextMessage; //导入依赖的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;
}
示例2: onCreate
import io.rong.message.TextMessage; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read_receipt_detail);
Intent intent = getIntent();
mMessage = intent.getParcelableExtra("message");
if (mMessage == null) {
return;
}
if (mMessage != null) {
mTextMessage = (TextMessage) mMessage.getContent();
}
initViews();
LoadDialog.show(mContext);
if (mMessage.getConversationType() == Conversation.ConversationType.GROUP) {
getGroupInfoFromDB();
}
setTitle(R.string.read_receipt_detail);
}
示例3: getMessageLoadToService
import io.rong.message.TextMessage; //导入依赖的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;
}
示例4: onConversationClick
import io.rong.message.TextMessage; //导入依赖的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;
}
示例5: sendRemindMessage
import io.rong.message.TextMessage; //导入依赖的package包/类
private void sendRemindMessage(Conversation.ConversationType conversationType, String targetId, String content) {
RongIM.getInstance().sendMessage(conversationType, targetId, TextMessage.obtain(content), null, null, new RongIMClient.SendMessageCallback() {
@Override
public void onError(Integer messageId, RongIMClient.ErrorCode e) {
}
@Override
public void onSuccess(Integer integer) {
}
});
}
示例6: setOnClick
import io.rong.message.TextMessage; //导入依赖的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);
}
});
}
示例7: getItemViewType
import io.rong.message.TextMessage; //导入依赖的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;
}
示例8: getMessageContent
import io.rong.message.TextMessage; //导入依赖的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;
}
示例9: translateMessageContent
import io.rong.message.TextMessage; //导入依赖的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;
}
示例10: onSent
import io.rong.message.TextMessage; //导入依赖的package包/类
/**
* 消息在UI展示后执行/自己的消息发出后执行,无论成功或失败。
*
* @param message 消息。
*/
@Override
public boolean onSent(Message message, RongIM.SentMessageErrorCode sentMessageErrorCode) {
Log.e("qinxiao", "onSent:" + message.getObjectName() + ", extra=" + message.getExtra());
if (message.getSentStatus() == Message.SentStatus.FAILED) {
if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_CHATROOM) {//不在聊天室
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_DISCUSSION) {//不在讨论组
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_GROUP) {//不在群组
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.REJECTED_BY_BLACKLIST) {//你在他的黑名单中
//WinToast.toast(mContext, "你在对方的黑名单中");
}
}
MessageContent messageContent = message.getContent();
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
Log.e(TAG, "onSent-TextMessage:" + textMessage.getContent());
} else if (messageContent instanceof ImageMessage) {//图片消息
ImageMessage imageMessage = (ImageMessage) messageContent;
Log.d(TAG, "onSent-ImageMessage:" + imageMessage.getRemoteUri());
} else if (messageContent instanceof VoiceMessage) {//语音消息
VoiceMessage voiceMessage = (VoiceMessage) messageContent;
Log.d(TAG, "onSent-voiceMessage:" + voiceMessage.getUri().toString());
} else if (messageContent instanceof RichContentMessage) {//图文消息
RichContentMessage richContentMessage = (RichContentMessage) messageContent;
Log.d(TAG, "onSent-RichContentMessage:" + richContentMessage.getContent());
} else {
Log.d(TAG, "onSent-其他消息,自己来判断处理");
}
return false;
}
示例11: setDateView
import io.rong.message.TextMessage; //导入依赖的package包/类
/**
* @ 消息提示
* @param holder
* @param data
*/
private void setDateView(ViewHolder holder, UIConversation data) {
String userId = null;
String username = null;
if (FlyingIMContext.getInstance() != null) {
userId = FlyingDataManager.getCurrentRongID();
username = FlyingDataManager.getNickName();
}
MessageContent messageContent = data.getMessageContent();
if (messageContent instanceof TextMessage) {
if (((TextMessage) messageContent).getContent().contains("@" + userId)
|| ((TextMessage) messageContent).getContent().contains("@" + username)) {
if (data.getUnReadMessageCount() == 0) {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
} else if (data.getUnReadMessageCount() > 0) {
holder.atMe.setVisibility(View.VISIBLE);
data.setExtraFlag(true);
}
} else {
if (data.getExtraFlag()) {
holder.atMe.setVisibility(View.VISIBLE);
} else {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
}
if (data.getUnReadMessageCount() == 0) {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
}
}
}
}
开发者ID:birdcopy,项目名称:Android-Birdcopy-Application,代码行数:44,代码来源:NewDiscussionConversationProvider.java
示例12: onSent
import io.rong.message.TextMessage; //导入依赖的package包/类
/**
* 消息在UI展示后执行/自己的消息发出后执行,无论成功或失败。
*
* @param message 消息。
*/
@Override
public boolean onSent(Message message, RongIM.SentMessageErrorCode sentMessageErrorCode) {
Log.e("qinxiao", "onSent:" + message.getObjectName() + ", extra=" + message.getExtra());
if (message.getSentStatus() == Message.SentStatus.FAILED) {
if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_CHATROOM) {//不在聊天室
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_DISCUSSION) {//不在讨论组
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.NOT_IN_GROUP) {//不在群组
} else if (sentMessageErrorCode == RongIM.SentMessageErrorCode.REJECTED_BY_BLACKLIST) {//你在他的黑名单中
WinToast.toast(mContext, "你在对方的黑名单中");
}
}
MessageContent messageContent = message.getContent();
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
Log.e(TAG, "onSent-TextMessage:" + textMessage.getContent());
} else if (messageContent instanceof ImageMessage) {//图片消息
ImageMessage imageMessage = (ImageMessage) messageContent;
Log.d(TAG, "onSent-ImageMessage:" + imageMessage.getRemoteUri());
} else if (messageContent instanceof VoiceMessage) {//语音消息
VoiceMessage voiceMessage = (VoiceMessage) messageContent;
Log.d(TAG, "onSent-voiceMessage:" + voiceMessage.getUri().toString());
} else if (messageContent instanceof RichContentMessage) {//图文消息
RichContentMessage richContentMessage = (RichContentMessage) messageContent;
Log.d(TAG, "onSent-RichContentMessage:" + richContentMessage.getContent());
} else {
Log.d(TAG, "onSent-其他消息,自己来判断处理");
}
return false;
}
示例13: setDateView
import io.rong.message.TextMessage; //导入依赖的package包/类
/**
* @ 消息提示
* @param holder
* @param data
*/
private void setDateView(ViewHolder holder, UIConversation data) {
String userId = null;
String username = null;
if (DemoContext.getInstance() != null) {
userId = DemoContext.getInstance().getSharedPreferences().getString(Constants.APP_USER_ID, Constants.DEFAULT);
username = DemoContext.getInstance().getSharedPreferences().getString(Constants.APP_USER_NAME, Constants.DEFAULT);
}
MessageContent messageContent = data.getMessageContent();
if (messageContent instanceof TextMessage) {
if (((TextMessage) messageContent).getContent().contains("@" + userId)
|| ((TextMessage) messageContent).getContent().contains("@" + username)) {
if (data.getUnReadMessageCount() == 0) {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
} else if (data.getUnReadMessageCount() > 0) {
holder.atMe.setVisibility(View.VISIBLE);
data.setExtraFlag(true);
}
} else {
if (data.getExtraFlag()) {
holder.atMe.setVisibility(View.VISIBLE);
} else {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
}
if (data.getUnReadMessageCount() == 0) {
holder.atMe.setVisibility(View.GONE);
data.setExtraFlag(false);
}
}
}
}
开发者ID:yangyunfeng666,项目名称:demo-app-android-v2-2.3.9,代码行数:43,代码来源:NewDiscussionConversationProvider.java
示例14: TranslatedTextMessage
import io.rong.message.TextMessage; //导入依赖的package包/类
public TranslatedTextMessage(MessageContent content) {
TextMessage textMessage = (TextMessage) content;
this.text = textMessage.getContent() == null ? "" : textMessage.getContent();
this.extra = textMessage.getExtra() == null ? "" : textMessage.getExtra();
}
示例15: onReceived
import io.rong.message.TextMessage; //导入依赖的package包/类
/**
* 接收消息的监听器:OnReceiveMessageListener 的回调方法,接收到消息后执行。
*
* @param message 接收到的消息的实体信息。
* @param left 剩余未拉取消息数目。
*/
@Override
public boolean onReceived(Message message, int left) {
MessageContent messageContent = message.getContent();
if (messageContent instanceof TextMessage) {//文本消息
TextMessage textMessage = (TextMessage) messageContent;
textMessage.getExtra();
Log.d(TAG, "onReceived-TextMessage:" + textMessage.getContent());
} else if (messageContent instanceof ImageMessage) {//图片消息
ImageMessage imageMessage = (ImageMessage) messageContent;
Log.d(TAG, "onReceived-ImageMessage:" + imageMessage.getRemoteUri());
} else if (messageContent instanceof VoiceMessage) {//语音消息
VoiceMessage voiceMessage = (VoiceMessage) messageContent;
Log.d(TAG, "onReceived-voiceMessage:" + voiceMessage.getUri().toString());
} else if (messageContent instanceof RichContentMessage) {//图文消息
RichContentMessage richContentMessage = (RichContentMessage) messageContent;
Log.d(TAG, "onReceived-RichContentMessage:" + richContentMessage.getContent());
} else if (messageContent instanceof InformationNotificationMessage) {//小灰条消息
InformationNotificationMessage informationNotificationMessage = (InformationNotificationMessage) messageContent;
Log.e(TAG, "onReceived-informationNotificationMessage:" + informationNotificationMessage.getMessage());
//if (FlyingIMContext.getInstance() != null)
// getFriendByUserIdHttpRequest = FlyingIMContext.getInstance().getUserInfoByUserId(message.getSenderUserId(), (ApiCallback<User>) this);
}
/*else if (messageContent instanceof AgreedFriendRequestMessage) {//好友添加成功消息
AgreedFriendRequestMessage agreedFriendRequestMessage = (AgreedFriendRequestMessage) messageContent;
Log.d(TAG, "onReceived-deAgreedFriendRequestMessage:" + agreedFriendRequestMessage.getMessage());
Intent in = new Intent();
in.setAction(MainActivity.ACTION_DMEO_AGREE_REQUEST);
in.putExtra("AGREE_REQUEST", true);
mContext.sendBroadcast(in);
} else if (messageContent instanceof ContactNotificationMessage) {//好友添加消息
ContactNotificationMessage contactContentMessage = (ContactNotificationMessage) messageContent;
Log.d(TAG, "onReceived-ContactNotificationMessage:getExtra;" + contactContentMessage.getExtra());
Log.d(TAG, "onReceived-ContactNotificationMessage:+getmessage:" + contactContentMessage.getMessage().toString());
Intent in = new Intent();
in.setAction(MainActivity.ACTION_DMEO_RECEIVE_MESSAGE);
in.putExtra("rongCloud", contactContentMessage);
in.putExtra("has_message", true);
mContext.sendBroadcast(in);
}
*/else if (messageContent instanceof DiscussionNotificationMessage) {//讨论组通知消息
DiscussionNotificationMessage discussionNotificationMessage = (DiscussionNotificationMessage) messageContent;
Log.d(TAG, "onReceived-discussionNotificationMessage:getExtra;" + discussionNotificationMessage.getOperator());
setDiscussionName(message.getTargetId());
} else {
Log.d(TAG, "onReceived-其他消息,自己来判断处理");
}
//通知更新菜单
Intent in = new Intent();
in.setAction(MainActivity.ACTION_RONGCLOUD_RECEIVE_MESSAGE);
in.putExtra("rongMessage", message);
in.putExtra("has_message", true);
mContext.sendBroadcast(in);
return false;
}