1 package com.netease.nimlib.sdk.chatroom;
3 import android.content.Context;
4 import android.net.Uri;
5 import android.text.TextUtils;
44 ChatRoomMessageImpl msg = initSendMessage(roomId);
71 ChatRoomMessageImpl msg = initSendMessage(roomId);
74 ((FileAttachment) attachment).setNosTokenSceneKey(nosTokenScene);
76 msg.setAttachment(attachment);
118 ChatRoomMessageImpl msg = initSendMessage(roomId);
122 msg.setAttachment(attachment);
137 ChatRoomMessageImpl msg = initSendMessage(roomId);
140 msg.setAttachment(attachment);
181 ChatRoomMessageImpl msg = initSendMessage(roomId);
183 if (duration > 0 && duration < 1000) {
188 msg.setAttachment(attachment);
204 ChatRoomMessageImpl msg = initSendMessage(roomId);
206 if (duration > 0 && duration < 1000) {
210 msg.setAttachment(attachment);
225 ChatRoomMessageImpl msg = initSendMessage(roomId);
233 msg.setAttachment(location);
266 return createChatRoomVideoMessage(context,roomId, uri, duration, width, height, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
282 ChatRoomMessageImpl msg = initSendMessage(roomId);
286 msg.setAttachment(attachment);
306 @SuppressWarnings(
"java:S107")
308 ChatRoomMessageImpl msg = initSendMessage(roomId);
312 msg.setAttachment(attachment);
341 ChatRoomMessageImpl msg = initSendMessage(roomId);
345 msg.setAttachment(attachment);
359 ChatRoomMessageImpl msg = initSendMessage(roomId);
363 msg.setAttachment(attachment);
378 ChatRoomMessageImpl msg = initSendMessage(roomId);
382 msg.setAttachment(attachment);
397 ChatRoomMessageImpl msg = initSendMessage(roomId);
399 msg.setContent(text);
413 ChatRoomMessageImpl msg = initSendMessage(roomId);
430 if (TextUtils.isEmpty(type) || TextUtils.isEmpty(robotAccount)) {
431 throw new IllegalArgumentException(
"Invalid param, type and robot account should not be null");
435 throw new IllegalArgumentException(
"Invalid param, content should not be null");
437 throw new IllegalArgumentException(
"Invalid param, target should not be null");
440 ChatRoomMessageImpl msg = initSendMessage(roomId);
445 robotAttachment.
initSend(robotAccount, type, content, target, params);
446 msg.setAttachment(robotAttachment);
447 msg.setContent(text);
459 ChatRoomMessageImpl msg =
new ChatRoomMessageImpl();
460 msg.setSessionId(roomId);
467 private final static ChatRoomMessageImpl initSendMessage(String roomId) {
468 ChatRoomMessageImpl msg =
new ChatRoomMessageImpl();
469 msg.setUuid(StringUtil.get32UUID());
470 msg.setSessionId(roomId);
471 msg.setFromAccount(SDKCacheUI.getChatRoomAccount());
475 msg.setTime(TimeUtil.currentTimeMillis());
static ChatRoomMessage createChatRoomSpatialLocationTextMessage(String roomId, String text, Double x, Double y, Double z)
创建普通文本消息
static ChatRoomMessage createChatRoomTextMessage(String roomId, String text)
创建普通文本消息
static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName, String nosTokenSceneKey)
创建一条视频消息 并指定视频文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment, String nosTokenScene)
创建自定义消息 另外指定指定文件上传(如果有)时使用的 nos scene
.annotation.NonNull static FileAttachment createFileAttachment(File file, String displayName, String nosTokenSceneKey)
创建文件附件。用于上传文件。
static ChatRoomMessage createChatRoomImageMessage(Context context, String roomId, Uri uri, String displayName)
创建一条图片消息
static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration, String nosTokenSceneKey)
创建一条音频消息 并指定音频文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomImageMessage(Context context, String roomId, Uri uri, String displayName, String nosTokenSceneKey)
创建一条图片消息 并指定图片上传时使用的 nos scene
.annotation.NonNull static VideoAttachment createVideoAttachment(File file, long duration, int width, int height, String displayName, String nosTokenSceneKey)
创建视频附件。用于上传视频文件。
云信 IM 消息构造器,提供构建各类型消息的接口。
void setLongitude(double longitude)
设置经度
消息本身发送/接收状态,附件状态见AttachStatusEnum
static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName, String nosTokenSceneKey)
创建一条图片消息 并指定图片上传时使用的 nos scene
static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName)
创建一条文件消息
static ChatRoomMessage createTipMessage(String roomId)
创建一条提醒消息
static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName)
创建一条视频消息
.annotation.NonNull static AudioAttachment createAudioAttachment(File file, long duration, String nosTokenSceneKey)
创建音频附件。用于上传音频文件。
.annotation.NonNull static ImageAttachment createImageAttachment(File file, String displayName, String nosTokenSceneKey)
创建图片附件,用于上传图片文件。
void initSend(String robotAccount, String type, String content, String target, String params)
String getThumbPathForSave()
获取用于保存缩略图文件的位置
static ChatRoomMessage createChatRoomFileMessage(Context context, String roomId, Uri uri, String displayName, String nosTokenSceneKey)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomVideoMessage(Context context, String roomId, Uri uri, long duration, int width, int height, String displayName)
创建一条视频消息
void setAddress(String address)
设置地理位置描述信息
static ChatRoomMessage createEmptyChatRoomMessage(String roomId, long time)
创建一条空消息,仅设置了房间ID以及时间点,用于记录查询
void setLatitude(double latitude)
设置纬度
static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment)
创建自定义消息
static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration)
创建一条音频消息
static ChatRoomMessage createChatRoomLocationMessage(String roomId, double lat, double lng, String addr)
创建一条地理位置信息
static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName, String nosTokenSceneKey)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomFileMessage(Context context, String roomId, Uri uri, String displayName)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomAudioMessage(Context context, String roomId, Uri uri, long duration, String nosTokenSceneKey)
创建一条音频消息 并指定音频文件上传时使用的 nos scene
static ChatRoomMessage createRobotMessage(String roomId, String robotAccount, String text, String type, String content, String target, String params)
static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName)
创建一条图片消息
static ChatRoomMessage createChatRoomAudioMessage(Context context, String roomId, Uri uri, long duration)
创建一条音频消息