@Override public void run() { // 封装image类型的IM消息 final ImageMessage content = ImageMessage.obtain(mUri, mUri); if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) RongIM.getInstance() .getRongIMClient() .sendImageMessage( getCurrentConversation().getConversationType(), getCurrentConversation().getTargetId(), content, null, null, new RongIMClient.SendImageMessageCallback() { @Override public void onAttached(Message message) {} @Override public void onError(Message message, RongIMClient.ErrorCode errorCode) {} @Override public void onSuccess(Message message) {} @Override public void onProgress(Message message, int i) {} }); }
@Override public void run() { RLog.d(this, "AttachRunnable", "insert image and save to db, uri = " + mUri); final ImageMessage content = ImageMessage.obtain(mUri, mUri); if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) ; RongIM.getInstance() .getRongIMClient() .insertMessage( getCurrentConversation().getConversationType(), getCurrentConversation().getTargetId(), null, content, new RongIMClient.ResultCallback<Message>() { @Override public void onSuccess(Message message) { RLog.d(this, "AttachRunnable", "onSuccess insert image"); message.setSentStatus(Message.SentStatus.SENDING); RongIM.getInstance() .getRongIMClient() .setMessageSentStatus( message.getMessageId(), Message.SentStatus.SENDING, null); getContext().executorBackground(new UploadRunnable(message)); } @Override public void onError(RongIMClient.ErrorCode e) { RLog.d(this, "AttachRunnable", "onError insert image, error = " + e); } }); }