private void fireNewChatState(Chat chat, ChatState state) { for (ChatMessageListener listener : chat.getListeners()) { if (listener instanceof ChatStateListener) { ((ChatStateListener) listener).stateChanged(chat, state); } } }
@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(); } }