当前位置: 首页>>代码示例>>Java>>正文


Java EMMessage.getStringAttribute方法代码示例

本文整理汇总了Java中com.hyphenate.chat.EMMessage.getStringAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java EMMessage.getStringAttribute方法的具体用法?Java EMMessage.getStringAttribute怎么用?Java EMMessage.getStringAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hyphenate.chat.EMMessage的用法示例。


在下文中一共展示了EMMessage.getStringAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAtMeMsg

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
public boolean isAtMeMsg(EMMessage message){
    EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
    if(user != null){
        try {
            JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
            
            for(int i = 0; i < jsonArray.length(); i++){
                String username = jsonArray.getString(i);
                if(username.equals(EMClient.getInstance().getCurrentUser())){
                    return true;
                }
            }
        } catch (Exception e) {
            //perhaps is a @ all message
            String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
            if(atUsername != null){
                if(atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
                    return true;
                }
            }
            return  false;
        }
        
    }
    return false;
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:27,代码来源:EaseAtMessageHelper.java

示例2: isAtMeMsg

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
public boolean isAtMeMsg(EMMessage message){
    EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
    if(user != null){
        try {
            JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);

            for(int i = 0; i < jsonArray.length(); i++){
                String username = jsonArray.getString(i);
                if(username.equals(EMClient.getInstance().getCurrentUser())){
                    return true;
                }
            }
        } catch (Exception e) {
            //perhaps is a @ all message
            String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
            if(atUsername != null){
                if(atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
                    return true;
                }
            }
            return  false;
        }

    }
    return false;
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:27,代码来源:EaseAtMessageHelper.java

示例3: isAtMeMsg

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
public boolean isAtMeMsg(EMMessage message) {
    EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
    if (user != null) {
        try {
            JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);

            for (int i = 0; i < jsonArray.length(); i++) {
                String username = jsonArray.getString(i);
                if (username.equals(EMClient.getInstance().getCurrentUser())) {
                    return true;
                }
            }
        } catch (Exception e) {
            //perhaps is a @ all message
            String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
            if (atUsername != null) {
                if (atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)) {
                    return true;
                }
            }
            return false;
        }

    }
    return false;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:27,代码来源:EaseAtMessageHelper.java

示例4: parseMessages

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * parse the message, get and save group id if I was mentioned(@)
 * @param messages
 */
public void parseMessages(List<EMMessage> messages) {
    int size = atMeGroupList.size();
    EMMessage[] msgs = messages.toArray(new EMMessage[messages.size()]);
    for(EMMessage msg : msgs){
        if(msg.getChatType() == ChatType.GroupChat){
            String groupId = msg.getTo();
            try {
                JSONArray jsonArray = msg.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
                for(int i = 0; i < jsonArray.length(); i++){
                    String username = jsonArray.getString(i);
                    if(EMClient.getInstance().getCurrentUser().equals(username)){
                        if(!atMeGroupList.contains(groupId)){
                            atMeGroupList.add(groupId);
                            break;
                        }
                    }
                }
            } catch (Exception e1) {
                //Determine whether is @ all message
                String usernameStr = msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
                if(usernameStr != null){
                    if(usernameStr.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
                        if(!atMeGroupList.contains(groupId)){
                            atMeGroupList.add(groupId);
                        }
                    }
                }
            }
            
            if(atMeGroupList.size() != size){
                EasePreferenceManager.getInstance().setAtMeGroups(atMeGroupList);
            }
        }
    }
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:40,代码来源:EaseAtMessageHelper.java

示例5: parseMessages

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * parse the message, get and save group id if I was mentioned(@)
 * @param messages
 */
public void parseMessages(List<EMMessage> messages) {
    int size = atMeGroupList.size();
    EMMessage[] msgs = messages.toArray(new EMMessage[messages.size()]);
    for(EMMessage msg : msgs){
        if(msg.getChatType() == EMMessage.ChatType.GroupChat){
            String groupId = msg.getTo();
            try {
                JSONArray jsonArray = msg.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
                for(int i = 0; i < jsonArray.length(); i++){
                    String username = jsonArray.getString(i);
                    if(EMClient.getInstance().getCurrentUser().equals(username)){
                        if(!atMeGroupList.contains(groupId)){
                            atMeGroupList.add(groupId);
                            break;
                        }
                    }
                }
            } catch (Exception e1) {
                //Determine whether is @ all message
                String usernameStr = msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
                if(usernameStr != null){
                    if(usernameStr.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
                        if(!atMeGroupList.contains(groupId)){
                            atMeGroupList.add(groupId);
                        }
                    }
                }
            }

            if(atMeGroupList.size() != size){
                EasePreferenceManager.getInstance().setAtMeGroups(atMeGroupList);
            }
        }
    }
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:40,代码来源:EaseAtMessageHelper.java

示例6: parseMessages

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * parse the message, get and save group id if I was mentioned(@)
 *
 * @param messages
 */
public void parseMessages(List<EMMessage> messages) {
    int size = atMeGroupList.size();
    EMMessage[] msgs = messages.toArray(new EMMessage[messages.size()]);
    for (EMMessage msg : msgs) {
        if (msg.getChatType() == ChatType.GroupChat) {
            String groupId = msg.getTo();
            try {
                JSONArray jsonArray = msg.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
                for (int i = 0; i < jsonArray.length(); i++) {
                    String username = jsonArray.getString(i);
                    if (EMClient.getInstance().getCurrentUser().equals(username)) {
                        if (!atMeGroupList.contains(groupId)) {
                            atMeGroupList.add(groupId);
                            break;
                        }
                    }
                }
            } catch (Exception e1) {
                //Determine whether is @ all message
                String usernameStr = msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
                if (usernameStr != null) {
                    if (usernameStr.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)) {
                        if (!atMeGroupList.contains(groupId)) {
                            atMeGroupList.add(groupId);
                        }
                    }
                }
            }

            if (atMeGroupList.size() != size) {
               EasePreferenceManager.getInstance().setAtMeGroups(atMeGroupList);
            }
        }
    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:41,代码来源:EaseAtMessageHelper.java

示例7: wrapperRedPacketInfo

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * 封装拆红包所需参数
 *
 * @param chatType 聊天类型
 * @param message  EMMessage
 * @return RedPacketInfo
 */
private static RedPacketInfo wrapperRedPacketInfo(int chatType, EMMessage message) {
    String redPacketId = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_ID, "");
    RedPacketInfo redPacketInfo = new RedPacketInfo();
    redPacketInfo.redPacketId = redPacketId;
    redPacketInfo.messageDirect = getMessageDirect(message);
    redPacketInfo.chatType = chatType;
    return redPacketInfo;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:16,代码来源:RedPacketUtil.java

示例8: receiveRedPacketAckMessage

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * 使用cmd消息收取领到红包之后的回执消息
 */
public static void receiveRedPacketAckMessage(EMMessage message) {
    String senderNickname = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_NAME, "");
    String receiverNickname = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_RECEIVER_NAME, "");
    String senderId = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_ID, "");
    String receiverId = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_RECEIVER_ID, "");
    String groupId = message.getStringAttribute(RPConstant.EXTRA_RED_PACKET_GROUP_ID, "");
    String currentUser = EMClient.getInstance().getCurrentUser();
    //更新UI为 xx领取了你的红包
    if (currentUser.equals(senderId) && !receiverId.equals(senderId)) {//如果不是自己领取的红包更新此类消息UI
        EMMessage msg = EMMessage.createTxtSendMessage("content", groupId);
        msg.setChatType(EMMessage.ChatType.GroupChat);
        msg.setFrom(message.getFrom());
        if (TextUtils.isEmpty(groupId)) {
            msg.setTo(message.getTo());
        } else {
            msg.setTo(groupId);
        }
        msg.setMsgId(UUID.randomUUID().toString());
        msg.setMsgTime(message.getMsgTime());
        msg.setDirection(EMMessage.Direct.RECEIVE);
        msg.setUnread(false);//去掉未读的显示
        msg.setAttribute(RPConstant.MESSAGE_ATTR_IS_RED_PACKET_ACK_MESSAGE, true);
        msg.setAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_NAME, senderNickname);
        msg.setAttribute(RPConstant.EXTRA_RED_PACKET_RECEIVER_NAME, receiverNickname);
        msg.setAttribute(RPConstant.EXTRA_RED_PACKET_SENDER_ID, senderId);
        //保存消息
        EMClient.getInstance().chatManager().saveMessage(msg);
    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:33,代码来源:RedPacketUtil.java

示例9: isRandomRedPacket

import com.hyphenate.chat.EMMessage; //导入方法依赖的package包/类
/**
 * 判断红包类型是否为小额随机红包
 *
 * @param message EMMessage
 * @return true or false
 */
public static boolean isRandomRedPacket(EMMessage message) {
    String redPacketType = message.getStringAttribute(RPConstant.MESSAGE_ATTR_RED_PACKET_TYPE, "");
    return !TextUtils.isEmpty(redPacketType) && redPacketType.equals(RPConstant.RED_PACKET_TYPE_RANDOM);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:11,代码来源:RedPacketUtil.java


注:本文中的com.hyphenate.chat.EMMessage.getStringAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。