1 package com.netease.nimlib.sdk.chatroom;
3 import android.content.Context;
4 import android.net.Uri;
5 import android.text.TextUtils;
42 ChatRoomMessageImpl msg = initSendMessage(roomId);
69 ChatRoomMessageImpl msg = initSendMessage(roomId);
72 ((FileAttachment) attachment).setNosTokenSceneKey(nosTokenScene);
74 msg.setAttachment(attachment);
116 ChatRoomMessageImpl msg = initSendMessage(roomId);
120 msg.setAttachment(attachment);
135 ChatRoomMessageImpl msg = initSendMessage(roomId);
138 msg.setAttachment(attachment);
179 ChatRoomMessageImpl msg = initSendMessage(roomId);
181 if (duration > 0 && duration < 1000) {
186 msg.setAttachment(attachment);
202 ChatRoomMessageImpl msg = initSendMessage(roomId);
204 if (duration > 0 && duration < 1000) {
208 msg.setAttachment(attachment);
223 ChatRoomMessageImpl msg = initSendMessage(roomId);
231 msg.setAttachment(location);
264 return createChatRoomVideoMessage(context,roomId, uri, duration, width, height, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
280 ChatRoomMessageImpl msg = initSendMessage(roomId);
284 msg.setAttachment(attachment);
304 @SuppressWarnings(
"java:S107")
306 ChatRoomMessageImpl msg = initSendMessage(roomId);
310 msg.setAttachment(attachment);
339 ChatRoomMessageImpl msg = initSendMessage(roomId);
343 msg.setAttachment(attachment);
357 ChatRoomMessageImpl msg = initSendMessage(roomId);
361 msg.setAttachment(attachment);
376 ChatRoomMessageImpl msg = initSendMessage(roomId);
380 msg.setAttachment(attachment);
395 ChatRoomMessageImpl msg = initSendMessage(roomId);
397 msg.setContent(text);
411 ChatRoomMessageImpl msg = initSendMessage(roomId);
428 if (TextUtils.isEmpty(type) || TextUtils.isEmpty(robotAccount)) {
429 throw new IllegalArgumentException(
"Invalid param, type and robot account should not be null");
433 throw new IllegalArgumentException(
"Invalid param, content should not be null");
435 throw new IllegalArgumentException(
"Invalid param, target should not be null");
438 ChatRoomMessageImpl msg = initSendMessage(roomId);
443 robotAttachment.
initSend(robotAccount, type, content, target, params);
444 msg.setAttachment(robotAttachment);
445 msg.setContent(text);
457 ChatRoomMessageImpl msg =
new ChatRoomMessageImpl();
458 msg.setSessionId(roomId);
465 private final static ChatRoomMessageImpl initSendMessage(String roomId) {
466 ChatRoomMessageImpl msg =
new ChatRoomMessageImpl();
467 msg.setUuid(StringUtil.get32UUID());
468 msg.setSessionId(roomId);
469 msg.setFromAccount(SDKCache.getChatRoomAccount());
473 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)
创建一条音频消息