Java Code Examples for com.hyphenate.chat.EMMessage#getStringAttribute()
The following examples show how to use
com.hyphenate.chat.EMMessage#getStringAttribute() .
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: EaseAtMessageHelper.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: EaseAtMessageHelper.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
/** * 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); } } } }