Exemplo n.º 1
0
  public void refreshSession(String uid) {

    for (ChattingPeople people : adapter.getChattingPeoples()) {

      if (people.getPeople().equals(uid)) {

        adapter.getChattingPeoples().remove(people);

        people = chattPeopleService.findByUid(uid, hostUid);

        adapter.getChattingPeoples().add(0, people);

        break;
      }
    }
  }
Exemplo n.º 2
0
 public void onResume() {
   super.onResume();
   // 获取Activity对象 更新本个Fragment的列表,因为在Activity的onResume方法中从新获取了一遍聊天列表
   MainFragmentActivity activity = (MainFragmentActivity) getActivity();
   adapter.getChattingPeoples().clear();
   adapter.getChattingPeoples().addAll(activity.getChattingPeople());
   adapter.notifyDataSetChanged();
 };
Exemplo n.º 3
0
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {

    ChattingPeople people = adapter.getChattingPeoples().get(position);

    NearByPeople userInfo =
        new NearByPeople(
            people.getPeople(),
            people.getLastMsg().getAvatar(),
            0,
            0,
            "",
            0,
            0,
            0,
            0,
            0,
            0,
            people.getLastMsg().getName(),
            0,
            0,
            0,
            0,
            people.getLastMsg().getDistance(),
            "",
            "",
            0);

    Bundle bundle = new Bundle();

    bundle.putSerializable("user", userInfo);

    Intent intent = new Intent(getActivity(), ChatActivity.class);

    intent.putExtras(bundle);

    startActivity(intent);

    super.onListItemClick(l, v, position, id);
  }
Exemplo n.º 4
0
        public void handleMessage(android.os.Message msg) {
          // 取得这个消息表明在聊天窗口,更新聊天记录
          if (msg.what == CustomConst.HANDLER_CHATPEOPLE_LIST_UPDATE) {

            String uid = (String) msg.obj;

            refreshSession(uid);

            adapter.notifyDataSetChanged();

            // 取得这个消息表明原先没有这个会话,在消息列添加
          } else if (msg.what == CustomConst.HANDLER_CHATPEOPLE_LIST_ADD) {

            String uid = (String) msg.obj;
            // 将该会话如果要打开聊天窗口,要获取的聊天记录页数
            PiLinApplication.mUsrChatMsgPage.put(uid, 1);

            cPeopleDAO.save(uid, hostUid);

            adapter.getChattingPeoples().add(chattPeopleService.findByUid(uid, hostUid));

            adapter.notifyDataSetChanged();
          }
        }