本文整理汇总了Java中com.hyphenate.chat.EMMessage.getJSONArrayAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java EMMessage.getJSONArrayAttribute方法的具体用法?Java EMMessage.getJSONArrayAttribute怎么用?Java EMMessage.getJSONArrayAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hyphenate.chat.EMMessage
的用法示例。
在下文中一共展示了EMMessage.getJSONArrayAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}