本文整理汇总了Java中com.hyphenate.chat.EMMessage.getType方法的典型用法代码示例。如果您正苦于以下问题:Java EMMessage.getType方法的具体用法?Java EMMessage.getType怎么用?Java EMMessage.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hyphenate.chat.EMMessage
的用法示例。
在下文中一共展示了EMMessage.getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCustomChatRowType
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
@Override
public int getCustomChatRowType(EMMessage message) {
if (message.getType() == EMMessage.Type.TXT) {
//voice call
if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE_CALL : MESSAGE_TYPE_SENT_VOICE_CALL;
} else if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) {
//video call
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO_CALL : MESSAGE_TYPE_SENT_VIDEO_CALL;
}
//red packet code : 红包消息、红包回执消息以及转账消息的chatrow type
else if (RedPacketUtil.isRandomRedPacket(message)) {
//小额随机红包
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_RANDOM : MESSAGE_TYPE_SEND_RANDOM;
} else if (message.getBooleanAttribute(RPConstant.MESSAGE_ATTR_IS_RED_PACKET_MESSAGE, false)) {
//发送红包消息
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_RED_PACKET : MESSAGE_TYPE_SEND_RED_PACKET;
} else if (message.getBooleanAttribute(RPConstant.MESSAGE_ATTR_IS_RED_PACKET_ACK_MESSAGE, false)) {
//领取红包消息
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_RED_PACKET_ACK : MESSAGE_TYPE_SEND_RED_PACKET_ACK;
}
//end of red packet code
}
return 0;
}
示例2: getCustomChatRow
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
@Override
public EaseChatRow getCustomChatRow(EMMessage message, int position, BaseAdapter adapter) {
if (message.getType() == EMMessage.Type.TXT) {
// voice call or video call
if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) ||
message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) {
return new ChatRowVoiceCall(getActivity(), message, position, adapter);
}
// //red packet code : 红包消息、红包回执消息以及转账消息的chat row
// else if (RedPacketUtil.isRandomRedPacket(message)) {//小额随机红包
// return new ChatRowRandomPacket(getActivity(), message, position, adapter);
// } else if (message.getBooleanAttribute(RPConstant.MESSAGE_ATTR_IS_RED_PACKET_MESSAGE, false)) {//红包消息
// return new ChatRowRedPacket(getActivity(), message, position, adapter);
// } else if (message.getBooleanAttribute(RPConstant.MESSAGE_ATTR_IS_RED_PACKET_ACK_MESSAGE, false)) {//红包回执消息
// return new ChatRowRedPacketAck(getActivity(), message, position, adapter);
// }
//end of red packet code
}
return null;
}
示例3: getItemViewType
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* get type of item
*/
public int getItemViewType(int position) {
EMMessage message = getItem(position);
if (message == null) {
return -1;
}
if(customRowProvider != null && customRowProvider.getCustomChatRowType(message) > 0){
return customRowProvider.getCustomChatRowType(message) + 13;
}
if (message.getType() == EMMessage.Type.TXT) {
if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_EXPRESSION : MESSAGE_TYPE_SENT_EXPRESSION;
}
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
}
if (message.getType() == EMMessage.Type.IMAGE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;
}
if (message.getType() == EMMessage.Type.LOCATION) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
}
if (message.getType() == EMMessage.Type.VOICE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
}
if (message.getType() == EMMessage.Type.VIDEO) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
}
if (message.getType() == EMMessage.Type.FILE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
}
return -1;// invalid
}
示例4: forwardMessage
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例5: forwardMessage
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例6: forwardMessage
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
}else{
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例7: getItemViewType
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* get type of item
*/
public int getItemViewType(int position) {
EMMessage message = getItem(position);
if (message == null) {
return -1;
}
if(customRowProvider != null && customRowProvider.getCustomChatRowType(message) > 0){
return customRowProvider.getCustomChatRowType(message) + 13;
}
if (message.getType() == EMMessage.Type.TXT) {
if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_EXPRESSION : MESSAGE_TYPE_SENT_EXPRESSION;
}
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
}
if (message.getType() == EMMessage.Type.IMAGE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;
}
if (message.getType() == EMMessage.Type.LOCATION) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
}
if (message.getType() == EMMessage.Type.VOICE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
}
if (message.getType() == EMMessage.Type.VIDEO) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
}
if (message.getType() == EMMessage.Type.FILE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
}
return -1;// invalid
}
示例8: createChatRow
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
protected EaseChatRow createChatRow(Context context, EMMessage message, int position) {
EaseChatRow chatRow = null;
if(customRowProvider != null && customRowProvider.getCustomChatRow(message, position, this) != null){
return customRowProvider.getCustomChatRow(message, position, this);
}
switch (message.getType()) {
case TXT:
if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
chatRow = new EaseChatRowBigExpression(context, message, position, this);
}else{
chatRow = new EaseChatRowText(context, message, position, this);
}
break;
case LOCATION:
chatRow = new EaseChatRowLocation(context, message, position, this);
break;
case FILE:
chatRow = new EaseChatRowFile(context, message, position, this);
break;
case IMAGE:
chatRow = new EaseChatRowImage(context, message, position, this);
break;
case VOICE:
chatRow = new EaseChatRowVoice(context, message, position, this);
break;
case VIDEO:
chatRow = new EaseChatRowVideo(context, message, position, this);
break;
default:
break;
}
return chatRow;
}
示例9: getItemViewType
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* get type of item
*/
public int getItemViewType(int position) {
EMMessage message = getItem(position);
if (message == null) {
return -1;
}
if (customRowProvider != null && customRowProvider.getCustomChatRowType(message) > 0) {
return customRowProvider.getCustomChatRowType(message) + 13;
}
if (message.getType() == EMMessage.Type.TXT) {
if (message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_EXPRESSION : MESSAGE_TYPE_SENT_EXPRESSION;
}
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
}
if (message.getType() == EMMessage.Type.IMAGE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;
}
if (message.getType() == EMMessage.Type.LOCATION) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
}
if (message.getType() == EMMessage.Type.VOICE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
}
if (message.getType() == EMMessage.Type.VIDEO) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
}
if (message.getType() == EMMessage.Type.FILE) {
return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
}
return -1;// invalid
}
示例10: forwardMessage
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* forward message
*
* @param forward_msg_id
*/
protected void forwardMessage(String forward_msg_id) {
final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id);
EMMessage.Type type = forward_msg.getType();
switch (type) {
case TXT:
if (forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(),
forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
} else {
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if (forward_msg.getChatType() == ChatType.ChatRoom) {
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
示例11: getMessageDigest
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
* Get digest according message type and content
*
* @param message
* @param context
* @return
*/
public static String getMessageDigest(EMMessage message, Context context) {
String digest = "";
switch (message.getType()) {
case LOCATION:
if (message.direct() == EMMessage.Direct.RECEIVE) {
digest = getString(context, R.string.location_recv);
digest = String.format(digest, message.getFrom());
return digest;
} else {
digest = getString(context, R.string.location_prefix);
}
break;
case IMAGE:
digest = getString(context, R.string.picture);
break;
case VOICE:
digest = getString(context, R.string.voice_prefix);
break;
case VIDEO:
digest = getString(context, R.string.video);
break;
case TXT:
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){
digest = getString(context, R.string.voice_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){
digest = getString(context, R.string.video_call) + txtBody.getMessage();
}else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){
if(!TextUtils.isEmpty(txtBody.getMessage())){
digest = txtBody.getMessage();
}else{
digest = getString(context, R.string.dynamic_expression);
}
}else{
digest = txtBody.getMessage();
}
break;
case FILE:
digest = getString(context, R.string.file);
break;
default:
EMLog.e(TAG, "error, unknow type");
return "";
}
return digest;
}
示例12: createChatRow
import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
protected EaseChatRow createChatRow(Context context, final EMMessage message, int position) {
EaseChatRow chatRow = null;
if (customRowProvider != null && customRowProvider.getCustomChatRow(message, position, this) != null) {
return customRowProvider.getCustomChatRow(message, position, this);
}
switch (message.getType()) {
case TXT:
if (message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)) {
chatRow = new EaseChatRowBigExpression(context, message, position, this);
} else {
// if (StringUtils.isNotEmpty(message.getStringAttribute("recTransfer", null))) {
// chatRow = new EaseChatRowRecSendMoney(context, message, position, this);
//// } else if (StringUtils.isNotEmpty(message.getStringAttribute("transfer", null))) {
// chatRow = new EaseChatRowSendMoney(context, message, position, this, this);
//// } else if (StringUtils.isNotEmpty(message.getStringAttribute("redPacket", null))) {
// chatRow = new EaseChatRowRedPacket(context, message, position, this, this);
//// } else if (StringUtils.isNotEmpty(message.getStringAttribute("groupRedPacket", null))) {
// chatRow = new EaseChatRowRedPacket(context, message, position, this, this);
// } else {
chatRow = new EaseChatRowText(context, message, position, this, mIRBack);
// }
}
break;
case LOCATION:
chatRow = new EaseChatRowLocation(context, message, position, this);
break;
case FILE:
chatRow = new EaseChatRowFile(context, message, position, this);
break;
case IMAGE:
chatRow = new EaseChatRowImage(context, message, position, this);
break;
case VOICE:
chatRow = new EaseChatRowVoice(context, message, position, this);
break;
case VIDEO:
chatRow = new EaseChatRowVideo(context, message, position, this);
break;
default:
break;
}
return chatRow;
}