cn.jpush.im.android.api.enums.ContentType Java Examples
The following examples show how to use
cn.jpush.im.android.api.enums.ContentType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChattingListAdapter.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 检查图片是否处于创建状态,如果是,则加入发送队列 */ private void checkSendingImgMsg() { for (Message msg : mMsgList) { if (msg.getStatus() == MessageStatus.created && msg.getContentType() == ContentType.image) { mMsgQueue.offer(msg); } } if (mMsgQueue.size() > 0) { Message message = mMsgQueue.element(); if (mConv.getType() == ConversationType.single) { sendNextImgMsg(message); } else { sendNextImgMsg(message); } notifyDataSetChanged(); } }
Example #2
Source File: ChatMsgActivity.java From Android-IM with Apache License 2.0 | 6 votes |
public void onEvent(MessageEvent event) { final Message message = event.getMessage(); runOnUiThread(new Runnable() { @Override public void run() { //创建一个消息对象 myMessage = new MyMessage(((TextContent) message.getContent()).getText(), IMessage.MessageType.RECEIVE_TEXT); myMessage.setMessage(message); myMessage.setMsgID(message.getServerMessageId()); myMessage.setText(((TextContent) message.getContent()).getText() + ""); myMessage.setTimeString(TimeUtils.ms2date("MM-dd HH:mm", message.getCreateTime())); myMessage.setUserInfo(new DefaultUser(JMessageClient.getMyInfo().getUserName(), "DeadPool", imgRecrive)); if (message.getContentType() == ContentType.text || message.getContentType().equals("text")) { mAdapter.addToStart(myMessage, true); mAdapter.notifyDataSetChanged(); } //收到消息时,添加到集合 list.add(myMessage); } }); //do your own business }
Example #3
Source File: MsgListAdapter.java From jmessage-android-uikit with MIT License | 6 votes |
private void showResendDialog(final ViewHolder holder, final Message msg) { OnClickListener listener = new OnClickListener() { @Override public void onClick(View view) { if (view.getId() == IdHelper.getViewID(mContext, "jmui_cancel_btn")) { mDialog.dismiss(); } else { mDialog.dismiss(); if (msg.getContentType() == ContentType.image) { resendImage(holder, msg); } else { resendTextOrVoice(holder, msg); } } } }; mDialog = DialogCreator.createResendDialog(mContext, listener); mDialog.getWindow().setLayout((int) (0.8 * mWidth), WindowManager.LayoutParams.WRAP_CONTENT); mDialog.show(); }
Example #4
Source File: JmessageFlutterPlugin.java From jmessage-flutter-plugin with MIT License | 5 votes |
private void downloadThumbImage(MethodCall call, final Result result) { HashMap<String, Object> map = call.arguments(); final Message msg; try { JSONObject params = new JSONObject(map); msg = JMessageUtils.getMessage(params); if (msg == null) { handleResult(ERR_CODE_MESSAGE, ERR_MSG_MESSAGE, result); return; } } catch (JSONException e) { e.printStackTrace(); handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result); return; } if (msg.getContentType() != ContentType.image) { handleResult(ERR_CODE_MESSAGE, "Message type isn't image", result); return; } ImageContent content = (ImageContent) msg.getContent(); content.downloadThumbnailImage(msg, new DownloadCompletionCallback() { @Override public void onComplete(int status, String desc, File file) { if (status == 0) { HashMap res= new HashMap(); res.put("messageId", msg.getId()); res.put("filePath", file.getAbsolutePath()); handleResult(res, status, desc, result); } else { handleResult(status, desc, result); } } }); }
Example #5
Source File: JmessageFlutterPlugin.java From jmessage-flutter-plugin with MIT License | 5 votes |
private void downloadOriginalImage(MethodCall call, final Result result) { HashMap<String, Object> map = call.arguments(); final Message msg; try { JSONObject params = new JSONObject(map); msg = JMessageUtils.getMessage(params); if (msg == null) { handleResult(ERR_CODE_MESSAGE, ERR_MSG_MESSAGE, result); return; } } catch (JSONException e) { e.printStackTrace(); handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result); return; } if (msg.getContentType() != ContentType.image) { handleResult(ERR_CODE_MESSAGE, "Message type isn't image", result); return; } ImageContent content = (ImageContent) msg.getContent(); content.downloadOriginImage(msg, new DownloadCompletionCallback() { @Override public void onComplete(int status, String desc, File file) { if (status == 0) { HashMap res= new HashMap(); res.put("messageId", msg.getId()); res.put("filePath", file.getAbsolutePath()); handleResult(res, status, desc, result); } else { handleResult(status, desc, result); } } }); }
Example #6
Source File: JmessageFlutterPlugin.java From jmessage-flutter-plugin with MIT License | 5 votes |
private void downloadVoiceFile(MethodCall call, final Result result) { HashMap<String, Object> map = call.arguments(); final Message msg; try { JSONObject params = new JSONObject(map); msg = JMessageUtils.getMessage(params); if (msg == null) { handleResult(ERR_CODE_MESSAGE, ERR_MSG_MESSAGE, result); return; } } catch (JSONException e) { e.printStackTrace(); handleResult(ERR_CODE_PARAMETER, ERR_MSG_PARAMETER, result); return; } if (msg.getContentType() != ContentType.voice) { handleResult(ERR_CODE_MESSAGE, "Message type isn't voice", result); return; } VoiceContent content = (VoiceContent) msg.getContent(); content.downloadVoiceFile(msg, new DownloadCompletionCallback() { @Override public void onComplete(int status, String desc, File file) { if (status == 0) { HashMap res= new HashMap(); res.put("messageId", msg.getId()); res.put("filePath", file.getAbsolutePath()); handleResult(res, status, desc, result); } else { handleResult(status, desc, result); } } }); }
Example #7
Source File: ChatItemController.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private ArrayList<Integer> getImgMsgIDList() { ArrayList<Integer> imgMsgIDList = new ArrayList<Integer>(); for (Message msg : mMsgList) { if (msg.getContentType() == ContentType.image) { imgMsgIDList.add(msg.getId()); } } return imgMsgIDList; }
Example #8
Source File: ChatDetailActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
/** * 接收群成员变化事件 * * @param event 消息事件 */ public void onEvent(MessageEvent event) { final cn.jpush.im.android.api.model.Message msg = event.getMessage(); if (msg.getContentType() == ContentType.eventNotification) { EventNotificationContent.EventNotificationType msgType = ((EventNotificationContent) msg .getContent()).getEventNotificationType(); switch (msgType) { //添加群成员事件特殊处理 case group_member_added: List<String> userNames = ((EventNotificationContent) msg.getContent()).getUserNames(); for (final String userName : userNames) { JMessageClient.getUserInfo(userName, new GetUserInfoCallback() { @Override public void gotResult(int status, String desc, UserInfo userInfo) { if (status == 0) { mChatDetailController.getAdapter().notifyDataSetChanged(); } } }); } break; case group_member_removed: break; case group_member_exit: break; } //无论是否添加群成员,刷新界面 android.os.Message handleMsg = mUIHandler.obtainMessage(); handleMsg.what = JGApplication.ON_GROUP_EVENT; Bundle bundle = new Bundle(); bundle.putLong(JGApplication.GROUP_ID, ((GroupInfo) msg.getTargetInfo()).getGroupID()); handleMsg.setData(bundle); handleMsg.sendToTarget(); } }
Example #9
Source File: MsgListAdapter.java From jmessage-android-uikit with MIT License | 5 votes |
/** * 检查图片是否处于创建状态,如果是,则加入发送队列 */ private void checkSendingImgMsg() { for (Message msg : mMsgList) { if (msg.getStatus() == MessageStatus.created && msg.getContentType() == ContentType.image) { mMsgQueue.offer(msg); } } }
Example #10
Source File: MsgListAdapter.java From jmessage-android-uikit with MIT License | 5 votes |
private ArrayList<Integer> getImgMsgIDList() { ArrayList<Integer> imgMsgIDList = new ArrayList<Integer>(); for (Message msg : mMsgList) { if (msg.getContentType() == ContentType.image) { imgMsgIDList.add(msg.getId()); } } return imgMsgIDList; }
Example #11
Source File: GroupDetailActivity.java From jmessage-android-uikit with MIT License | 5 votes |
/** * 接收群成员变化事件 * * @param event 消息事件 */ public void onEvent(MessageEvent event) { final cn.jpush.im.android.api.model.Message msg = event.getMessage(); if (msg.getContentType() == ContentType.eventNotification) { EventNotificationContent.EventNotificationType msgType = ((EventNotificationContent) msg .getContent()).getEventNotificationType(); switch (msgType) { //添加群成员事件特殊处理 case group_member_added: List<String> userNames = ((EventNotificationContent) msg.getContent()).getUserNames(); for (final String userName : userNames) { JMessageClient.getUserInfo(userName, new GetUserInfoCallback() { @Override public void gotResult(int status, String desc, UserInfo userInfo) { if (status == 0) { mAdapter.notifyDataSetChanged(); } else { HandleResponseCode.onHandle(mContext, status, false); } } }); } break; case group_member_removed: break; case group_member_exit: break; } //无论是否添加群成员,刷新界面 mHandler.sendEmptyMessage(ON_GROUP_EVENT); } }
Example #12
Source File: AudioFileFragment.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void initData() { new Thread(new Runnable() { @Override public void run() { Conversation conversation; if (mIsGroup) { conversation = JMessageClient.getGroupConversation(mGroupId); } else { conversation = JMessageClient.getSingleConversation(mUserName); } List<Message> allMessage = conversation.getAllMessage(); for (cn.jpush.im.android.api.model.Message msg : allMessage) { MessageContent content = msg.getContent(); if (content.getContentType() == ContentType.file) { String fileType = content.getStringExtra("fileType"); if (fileType != null && (fileType.equals("wav") || fileType.equals("mp3") || fileType.equals("wma") || fileType.equals("midi"))) { FileContent fileContent = (FileContent) content; String localPath = fileContent.getLocalPath(); long createTime = msg.getCreateTime(); long fileSize = fileContent.getFileSize(); Date date = new Date(createTime); SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); String time = format.format(date); FileItem item = new FileItem(localPath, fileContent.getFileName(), fileSize + "", time, msg.getId(), msg.getFromName(), msg); if (!sectionMap.containsKey(item.getDate())) { item.setSection(section); sectionMap.put(item.getDate(), section); section++; } else { item.setSection(sectionMap.get(item.getDate())); } mDocuments.add(item); } } mHandler.sendEmptyMessage(SCAN_OK); } } }).start(); }
Example #13
Source File: OtherFileFragment.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void initData() { new Thread(new Runnable() { @Override public void run() { Conversation conversation; if (mIsGroup) { conversation = JMessageClient.getGroupConversation(mGroupId); } else { conversation = JMessageClient.getSingleConversation(mUserName); } List<Message> allMessage = conversation.getAllMessage(); for (Message msg : allMessage) { MessageContent content = msg.getContent(); if (content.getContentType() == ContentType.file) { String fileType = content.getStringExtra("fileType"); if (fileType != null && !fileType.equals("mp4") && !fileType.equals("mov") && !fileType.equals("rm") && !fileType.equals("rmvb") && !fileType.equals("wmv") && !fileType.equals("avi") && !fileType.equals("3gp") && !fileType.equals("mkv") && !fileType.equals("wav") && !fileType.equals("mp3") && !fileType.equals("wma") && !fileType.equals("midi") && !fileType.equals("ppt") && !fileType.equals("pptx") && !fileType.equals("doc") && !fileType.equals("docx") && !fileType.equals("pdf") && !fileType.equals("xls") && !fileType.equals("xlsx") && !fileType.equals("txt") && !fileType.equals("wps")) { FileContent fileContent = (FileContent) content; String localPath = fileContent.getLocalPath(); long createTime = msg.getCreateTime(); long fileSize = fileContent.getFileSize(); Date date = new Date(createTime); SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); String time = format.format(date); FileItem item = new FileItem(localPath, fileContent.getFileName(), fileSize + "", time, msg.getId(), msg.getFromName(), msg); if (!sectionMap.containsKey(item.getDate())) { item.setSection(section); sectionMap.put(item.getDate(), section); section++; } else { item.setSection(sectionMap.get(item.getDate())); } mDocuments.add(item); } } mHandler.sendEmptyMessage(SCAN_OK); } } }).start(); }
Example #14
Source File: VideoFileFragment.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void initData() { new Thread(new Runnable() { @Override public void run() { Conversation conversation; if (mIsGroup) { conversation = JMessageClient.getGroupConversation(mGroupId); } else { conversation = JMessageClient.getSingleConversation(mUserName); } List<Message> allMessage = conversation.getAllMessage(); for (cn.jpush.im.android.api.model.Message msg : allMessage) { MessageContent content = msg.getContent(); if (content.getContentType() == ContentType.file) { String fileType = content.getStringExtra("fileType"); if (fileType != null && (fileType.equals("mp4") || fileType.equals("mov") || fileType.equals("rm") || fileType.equals("rmvb") || fileType.equals("wmv") || fileType.equals("avi") || fileType.equals("3gp") || fileType.equals("mkv"))) { FileContent fileContent = (FileContent) content; String localPath = fileContent.getLocalPath(); long createTime = msg.getCreateTime(); long fileSize = fileContent.getFileSize(); Date date = new Date(createTime); SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); String time = format.format(date); FileItem item = new FileItem(localPath, fileContent.getFileName(), fileSize + "", time, msg.getId(), msg.getFromName(), msg); if (!sectionMap.containsKey(item.getDate())) { item.setSection(section); sectionMap.put(item.getDate(), section); section++; } else { item.setSection(sectionMap.get(item.getDate())); } mDocuments.add(item); } } mHandler.sendEmptyMessage(SCAN_OK); } } }).start(); }
Example #15
Source File: DocumentFileFragment.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void initData() { new Thread(new Runnable() { @Override public void run() { Conversation conversation; if (mIsGroup) { conversation = JMessageClient.getGroupConversation(mGroupId); } else { conversation = JMessageClient.getSingleConversation(mUserName); } List<Message> allMessage = conversation.getAllMessage(); for (Message msg : allMessage) { MessageContent content = msg.getContent(); if (content.getContentType() == ContentType.file) { String fileType = content.getStringExtra("fileType"); if (fileType != null && (fileType.equals("ppt") || fileType.equals("pptx") || fileType.equals("doc") || fileType.equals("docx") || fileType.equals("pdf") || fileType.equals("xls") || fileType.equals("xlsx") || fileType.equals("txt") || fileType.equals("wps"))) { FileContent fileContent = (FileContent) content; String localPath = fileContent.getLocalPath(); long createTime = msg.getCreateTime(); long fileSize = fileContent.getFileSize(); Date date = new Date(createTime); SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); String time = format.format(date); FileItem item = new FileItem(localPath, fileContent.getFileName(), fileSize + "", time, msg.getId(), msg.getFromName(), msg); if (!sectionMap.containsKey(item.getDate())) { item.setSection(section); sectionMap.put(item.getDate(), section); section++; } else { item.setSection(sectionMap.get(item.getDate())); } mDocuments.add(item); } } mHandler.sendEmptyMessage(SCAN_OK); } } }).start(); }