コード例 #1
0
ファイル: Fragment_Msg.java プロジェクト: peterdocter/wechat
 @Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
   if (adpter.PublicMsg != null && position == 0) {
     // 打开订阅号列表页面
     Utils.start_Activity(getActivity(), PublishMsgListActivity.class);
   } else {
     parentActivity.updateUnreadLabel();
     EMConversation conversation = conversationList.get(position);
     Intent intent = new Intent(getActivity(), ChatActivity.class);
     Hashtable<String, String> ChatRecord = adpter.getChatRecord();
     if (ChatRecord != null) {
       if (conversation.isGroup()) {
         GroupInfo info = GloableParams.GroupInfos.get(conversation.getUserName());
         if (info != null) {
           intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
           intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
           intent.putExtra(Constants.NAME, info.getGroup_name()); // 设置标题
           getActivity().startActivity(intent);
         } else {
           intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
           intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
           intent.putExtra(Constants.NAME, "群聊"); // 设置标题
           getActivity().startActivity(intent);
         }
       } else {
         User user = GloableParams.Users.get(conversation.getUserName());
         if (user != null) {
           intent.putExtra(Constants.NAME, user.getUserName()); // 设置昵称
           intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
           intent.putExtra(Constants.User_ID, conversation.getUserName());
           getActivity().startActivity(intent);
         } else {
           intent.putExtra(Constants.NAME, "好友");
           intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
           intent.putExtra(Constants.User_ID, conversation.getUserName());
           getActivity().startActivity(intent);
         }
       }
     }
   }
 }
コード例 #2
0
ファイル: Fragment_Msg.java プロジェクト: peterdocter/wechat
 private void initViews() {
   conversationList.addAll(loadConversationsWithRecentChat());
   if (conversationList != null && conversationList.size() > 0) {
     layout.findViewById(R.id.txt_nochat).setVisibility(View.GONE);
     adpter = new NewMsgAdpter(getActivity(), conversationList);
     // TODO 加载订阅号信息 ,增加一个Item
     // if (GloableParams.isHasPulicMsg) {
     EMConversation nee = new EMConversation("100000");
     conversationList.add(0, nee);
     String time = Utils.getValue(getActivity(), "Time");
     String content = Utils.getValue(getActivity(), "Content");
     time = "下午 02:45";
     content = "[腾讯娱乐] 赵薇炒股日赚74亿";
     PublicMsgInfo msgInfo = new PublicMsgInfo();
     msgInfo.setContent(content);
     msgInfo.setMsg_ID("12");
     msgInfo.setTime(time);
     adpter.setPublicMsg(msgInfo);
     // }
     lvContact.setAdapter(adpter);
   } else {
     layout.findViewById(R.id.txt_nochat).setVisibility(View.VISIBLE);
   }
 }