Java 类org.jivesoftware.smack.chat.ChatMessageListener 实例源码

项目:Smack    文件:ChatStateManager.java   
private void fireNewChatState(Chat chat, ChatState state) {
    for (ChatMessageListener listener : chat.getListeners()) {
        if (listener instanceof ChatStateListener) {
            ((ChatStateListener) listener).stateChanged(chat, state);
        }
    }
}
项目:CustomerSupportChat    文件:ChatActivity.java   
@Override
protected void onPostExecute(String result) {
    super.onPostExecute(result);

    if(result.equals("connected")){
        try {
            ConnectedMessage();

            pb_progressbar.setVisibility(View.GONE);
            ll_chat_window.setVisibility(View.VISIBLE);

            mChatmanager = mChatmanager.getInstanceFor(mConnection);
            friendJID = (EntityJid) JidCreate.from(friendID);
            mChat = mChatmanager.createChat(friendJID, new ChatMessageListener() {
                public void processMessage(org.jivesoftware.smack.chat.Chat chat, Message message) {

            // receiving the chat message from the support executive
                    if(!message.getBody().trim().equals("")){
                        mChatFunctionModel = new Chat();
                        mChatFunctionModel.setGotMessage(message.getBody());
                        mChatFunctionModel.setGotTime(new Date().getTime());
                        mChatFunctionModel.setSentMessage("");
                        chatsList.add(mChatFunctionModel);

                        runOnUiThread(new Runnable() {
                            public void run() {
                                mAdapter.notifyDataSetChanged();
                                mRecyclerView.smoothScrollToPosition(chatsList.size());
                                et_msgToBeSent.setFocusable(true);
                            }
                        });
                    }
                }
            });
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        }
    }
    else{
        cannotConnectMessage();
    }

}