/** * 褰撹Е鍙慓etUserInfo鍚庯紝寰楀埌Conversation鍚庯紝鍒锋柊鐣岄潰 閫氬父瑙﹀彂鐨勬儏鍐垫槸鏂颁細璇濆垱寤烘椂鍒锋柊鐩爣澶村儚 * * @param conversationRefreshEvent */ public void onEvent(ConversationRefreshEvent conversationRefreshEvent) { Log.i(TAG, "ConversationRefreshEvent execute"); Conversation conv = conversationRefreshEvent.getConversation(); if (conv.getType() == ConversationType.single) { File file = conv.getAvatarFile(); if (file != null) { mConvListController.loadAvatarAndRefresh(conv.getTargetId(), file.getAbsolutePath()); } } else { mConvListController.getAdapter().notifyDataSetChanged(); } }
public void getAllSingleConversation(JSONArray data, CallbackContext callbackContext) { Log.i(TAG, " getAllSingleConversation \n" + data); List<Conversation> list = JMessageClient.getConversationList(); Log.i(TAG, "JMessageGetAllSingleConversation" + list.size()); JSONArray jsonRusult = new JSONArray(); for (int i = 0; i < list.size(); ++i) { Conversation conv = list.get(i); if (conv.getType() == ConversationType.single) { UserInfo info = (UserInfo) conv.getTargetInfo(); Message msg = conv.getLatestMessage(); String contentText = ""; if (msg != null) { switch (msg.getContentType()) { case text: { contentText = ((TextContent) msg.getContent()).getText(); } break; default: break; } } JSONObject jsonItem = new JSONObject(); try { jsonItem.put("username", info.getUserName()); jsonItem.put("nickname", info.getNickname()); // jsonItem.put("avatar", info.getAvatar()); jsonItem.put("lastMessage", contentText); jsonItem.put("unreadCount", conv.getUnReadMsgCnt()); jsonRusult.put(jsonItem); } catch (JSONException e) { e.printStackTrace(); } } } callbackContext.success(jsonRusult); }