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


Java EMNotifierEvent.getEvent方法代码示例

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


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

示例1: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
@Override
public void onEvent(EMNotifierEvent emNotifierEvent) {
    switch (emNotifierEvent.getEvent()) {
        case EventNewMessage: // 普通消息
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (menuLeftFragment!=null){
                        menuLeftFragment.setItemBackground(View.VISIBLE);
                    }
                }
            });

            LogUtil.e("MainActivity", "EventNewMessage !!!!!!!!!!!!!!!!!");
            break;
    }
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:18,代码来源:MainActivity.java

示例2: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
@Override
public void onEvent(EMNotifierEvent emNotifierEvent) {
    switch (emNotifierEvent.getEvent()) {
        case EventNewMessage: // 普通消息
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    handler.sendEmptyMessage(new Message().what = HAS_CHAT_MESSAGE);
                    SharePreferencesUtil.saveEMChatNewMessegeStatus(true);
                }
            });

            LogUtil.e("MainActivity", "EventNewMessage !!!!!!!!!!!!!!!!!");
            break;
    }
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:17,代码来源:MainActivity.java

示例3: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
	 * 监听事件
     */
	@Override
	public void onEvent(EMNotifierEvent event) {
		switch (event.getEvent()) {
		case EventNewMessage: // 普通消息
		{
//			EMMessage message = (EMMessage) event.getData();

			// 提示新消息
//			HXSDKHelper.getInstance().getNotifier().onNewMsg(message);
			refreshUI();
			break;
		}

		case EventOfflineMessage: {
			refreshUI();
			break;
		}

		case EventConversationListChanged: {
		    refreshUI();
		    break;
		}
		
		default:
			break;
		}
	}
 
开发者ID:chenjunqian,项目名称:here,代码行数:31,代码来源:EMChatMainActivity.java

示例4: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
 * 监听事件
 */
@Override
public void onEvent(EMNotifierEvent event) {
    switch (event.getEvent()) {
        case EventNewMessage: // 普通消息
        {
            EMMessage message = (EMMessage) event.getData();

            // 提示新消息
            DemoHelper.getInstance().getNotifier().onNewMsg(message);

            refreshUIWithMessage();
            break;
        }

        case EventOfflineMessage: {
            refreshUIWithMessage();
            break;
        }

        case EventConversationListChanged: {
            refreshUIWithMessage();
            break;
        }

        default:
            break;
    }
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:32,代码来源:MainActivity.java

示例5: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
 * 事件监听,registerEventListener后的回调事件
 * 
 * see {@link EMNotifierEvent}
 */
@Override
public void onEvent(EMNotifierEvent event) {
    switch (event.getEvent()) {
    case EventNewMessage:
        // 获取到message
        EMMessage message = (EMMessage) event.getData();

        String username = null;
        // 群组消息
        if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
            username = message.getTo();
        } else {
            // 单聊消息
            username = message.getFrom();
        }

        // 如果是当前会话的消息,刷新聊天页面
        if (username.equals(toChatUsername)) {
            messageList.refreshSelectLast();
            // 声音和震动提示有新消息
            EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
        } else {
            // 如果消息不是和当前聊天ID的消息
            EaseUI.getInstance().getNotifier().onNewMsg(message);
        }

        break;
    case EventDeliveryAck:
    case EventReadAck:
        // 获取到message
        messageList.refresh();
        break;
    case EventOfflineMessage:
        // a list of offline messages
        // List<EMMessage> offlineMessages = (List<EMMessage>)
        // event.getData();
        messageList.refresh();
        break;
    default:
        break;
    }

}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:49,代码来源:EaseChatFragment.java

示例6: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
 * 监听事件
    */
@Override
public void onEvent(EMNotifierEvent event) {
	switch (event.getEvent()) {
	case EventNewMessage: // 普通消息
		EMMessage message = (EMMessage) event.getData();
		// 提示新消息
		DemoHelper.getInstance().getNotifier().onNewMsg(message);

		refreshUIWithMessage();
		break;
	case EventOfflineMessage: {
	    refreshUIWithMessage();
		break;
	}

	case EventConversationListChanged: {
	    refreshUIWithMessage();
	    break;
	}
	case EventNewCMDMessage:
		EMMessage cmdMessage = (EMMessage) event.getData();
		//获取消息body
           CmdMessageBody cmdMsgBody = (CmdMessageBody) cmdMessage.getBody();
           final String action = cmdMsgBody.action;//获取自定义action
           if(action.equals(EaseConstant.EASE_ATTR_REVOKE)){
               EaseCommonUtils.receiveRevokeMessage(this, cmdMessage);
           }
		refreshUIWithMessage();
		break;
	case EventReadAck:
           // TODO 这里当此消息未加载到内存中时,ackMessage会为null,消息的删除会失败
	    EMMessage ackMessage = (EMMessage) event.getData();
	    EMConversation conversation = EMChatManager.getInstance().getConversation(ackMessage.getTo());
	    // 判断接收到ack的这条消息是不是阅后即焚的消息,如果是,则说明对方看过消息了,对方会销毁,这边也删除(现在只有txt iamge file三种消息支持 )
           if(ackMessage.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false) 
                   && (ackMessage.getType() == Type.TXT 
                   || ackMessage.getType() == Type.VOICE 
                   || ackMessage.getType() == Type.IMAGE)){
               // 判断当前会话是不是只有一条消息,如果只有一条消息,并且这条消息也是阅后即焚类型,当对方阅读后,这边要删除,会话会被过滤掉,因此要加载上一条消息
               if(conversation.getAllMessages().size() == 1 && conversation.getLastMessage().getMsgId().equals(ackMessage.getMsgId())){
                   if (ackMessage.getChatType() == ChatType.Chat) {
                       conversation.loadMoreMsgFromDB(ackMessage.getMsgId(), 1);
                   } else {
                       conversation.loadMoreGroupMsgFromDB(ackMessage.getMsgId(), 1);
                   }
               }
               conversation.removeMessage(ackMessage.getMsgId());
           }
           refreshUIWithMessage();
	    break;
	default:
		break;
	}
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:58,代码来源:MainActivity.java

示例7: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
 * 事件监听,registerEventListener后的回调事件
 * 
 * see {@link EMNotifierEvent}
 */
@Override
public void onEvent(EMNotifierEvent event) {
    switch (event.getEvent()) {
    case EventNewMessage:
        // 获取到message
        EMMessage message = (EMMessage) event.getData();

        String username = null;
        // 群组消息
        if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
            username = message.getTo();
        } else {
            // 单聊消息
            username = message.getFrom();
        }

        // 如果是当前会话的消息,刷新聊天页面
        if (username.equals(toChatUsername)) {
            messageList.refreshSelectLast();
            // 声音和震动提示有新消息
            EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
        } else {
            // 如果消息不是和当前聊天ID的消息
            EaseUI.getInstance().getNotifier().onNewMsg(message);
        }

        break;
    case EventDeliveryAck:
    case EventReadAck:
        // 获取到message
    	EMMessage ackMessage = (EMMessage) event.getData();
    	// 判断接收到ack的这条消息是不是阅后即焚的消息,如果是,则说明对方看过消息了,对方会销毁,这边也删除(现在只有txt iamge file三种消息支持 )
    	if(ackMessage.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false) 
    	        && (ackMessage.getType() == Type.TXT || ackMessage.getType() == Type.VOICE || ackMessage.getType() == Type.IMAGE)){
    		conversation.removeMessage(ackMessage.getMsgId());
    	}
        messageList.refresh();
        break;
    case EventOfflineMessage:
        // a list of offline messages
        // List<EMMessage> offlineMessages = (List<EMMessage>)
        // event.getData();
        messageList.refresh();
        break;
    case EventNewCMDMessage:
    	EMMessage cmdMessage = (EMMessage) event.getData();
    	//获取消息body
        CmdMessageBody cmdMsgBody = (CmdMessageBody) cmdMessage.getBody();
        final String action = cmdMsgBody.action;//获取自定义action
        if(action.equals(EaseConstant.EASE_ATTR_REVOKE)){
        	EaseCommonUtils.receiveRevokeMessage(getActivity(), cmdMessage);
        	messageList.refresh();
        }
    	break;
    default:
        break;
    }

}
 
开发者ID:easemob,项目名称:easeui,代码行数:65,代码来源:EaseChatFragment.java

示例8: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
	 * 事件监听
	 * 
	 * see {@link EMNotifierEvent}
     */
    @Override
    public void onEvent(EMNotifierEvent event) {
        switch (event.getEvent()) {
        case EventNewMessage:
        {
            //获取到message
            EMMessage message = (EMMessage) event.getData();
            
            String username = null;
            //群组消息
            if(message.getChatType() == ChatType.GroupChat){
                username = message.getTo();
            }
            else{
                //单聊消息
                username = message.getFrom();
            }

            //如果是当前会话的消息,刷新聊天页面
            if(username.equals(getToChatUsername())){
                refreshUIWithNewMessage();
                //声音和震动提示有新消息
                HXSDKHelper.getInstance().getNotifier().viberateAndPlayTone(message);
            }else{
                //如果消息不是和当前聊天ID的消息
                HXSDKHelper.getInstance().getNotifier().onNewMsg(message);
            }

            break;
        }
//        case EventDeliveryAck:
//        {
//            //获取到message
//            EMMessage message = (EMMessage) event.getData();
//            refreshUI();
//            break;
//        }
//        case EventReadAck:
//        {
//            //获取到message
//            EMMessage message = (EMMessage) event.getData();
//            refreshUI();
//            break;
//        }
        case EventOfflineMessage:
        {
            //a list of offline messages 
            //List<EMMessage> offlineMessages = (List<EMMessage>) event.getData();
            refreshUI();
            break;
        }
        default:
            break;
        }
        
    }
 
开发者ID:Owater,项目名称:school_shop,代码行数:62,代码来源:ChatActivity.java

示例9: onEvent

import com.easemob.EMNotifierEvent; //导入方法依赖的package包/类
/**
 * 事件监听,registerEventListener后的回调事件
 * <p/>
 * see {@link EMNotifierEvent}
 */
@Override
public void onEvent(EMNotifierEvent event) {
    switch (event.getEvent()) {
        case EventNewMessage:
            // 获取到message
            EMMessage message = (EMMessage) event.getData();

            String username = null;
            // 群组消息
            if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
                username = message.getTo();
            } else {
                // 单聊消息
                username = message.getFrom();
            }

            // 如果是当前会话的消息,刷新聊天页面
            if (username.equals(toChatUsername)) {
                messageList.refreshSelectLast();
                // 声音和震动提示有新消息
                EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
            } else {
                // 如果消息不是和当前聊天ID的消息
                EaseUI.getInstance().getNotifier().onNewMsg(message);
            }

            break;
        case EventDeliveryAck:
        case EventReadAck:
            // 获取到message
            messageList.refresh();
            break;
        case EventOfflineMessage:
            // a list of offline messages
            // List<EMMessage> offlineMessages = (List<EMMessage>)
            // event.getData();
            messageList.refresh();
            break;
        default:
            break;
    }

}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:49,代码来源:EaseChatFragment.java


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