@Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;
    errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item);
    errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg);

    topMap = MYApplication.getInstance().getTopUserList();
    normal_list.addAll(loadConversationsWithRecentChat());
    listView = (ListView) getView().findViewById(R.id.list);
    adapter = new ConversationAdapter(getActivity(), normal_list, top_list, topMap);
    // 设置adapter
    listView.setAdapter(adapter);
  }
예제 #2
0
  @SuppressLint("SdCardPath")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_userinfo);
    avatarLoader = new LoadUserAvatar(this, "/sdcard/fanxin/");
    Button btn_sendmsg = (Button) this.findViewById(R.id.btn_sendmsg);
    ImageView iv_avatar = (ImageView) this.findViewById(R.id.iv_avatar);
    ImageView iv_sex = (ImageView) this.findViewById(R.id.iv_sex);
    TextView tv_name = (TextView) this.findViewById(R.id.tv_name);
    final String nick = this.getIntent().getStringExtra("nick");
    final String avatar = this.getIntent().getStringExtra("avatar");
    String sex = this.getIntent().getStringExtra("sex");
    hxid = this.getIntent().getStringExtra("hxid");
    if (nick != null && avatar != null && sex != null && hxid != null) {
      tv_name.setText(nick);
      if (sex.equals("1")) {
        iv_sex.setImageResource(R.drawable.ic_sex_male);
      } else if (sex.equals("2")) {
        iv_sex.setImageResource(R.drawable.ic_sex_female);
      } else {
        iv_sex.setVisibility(View.GONE);
      }
      if (MYApplication.getInstance().getContactList().containsKey(hxid)) {
        is_friend = true;
        btn_sendmsg.setText("发消息");
      }

      showUserAvatar(iv_avatar, avatar);
    }

    btn_sendmsg.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (hxid.equals(
                LocalUserInfo.getInstance(getApplicationContext()).getUserInfo("hxid"))) {
              Toast.makeText(getApplicationContext(), "不能和自己聊天。。", Toast.LENGTH_SHORT).show();
              return;
            }
            if (is_friend) {
              Intent intent = new Intent();
              intent.putExtra("userId", hxid);
              intent.putExtra("userAvatar", avatar);
              intent.putExtra("userNick", nick);

              intent.setClass(UserInfoActivity.this, ChatActivity.class);
              startActivity(intent);
            } else {

              Intent intent = new Intent();
              intent.putExtra("hxid", hxid);
              // intent.putExtra("avatar", avatar);
              // intent.putExtra("nick", nick);

              intent.setClass(UserInfoActivity.this, AddFriendsFinalActivity.class);
              startActivity(intent);
            }
          }
        });

    Button btn_new = (Button) this.findViewById(R.id.btn_new);
    btn_new.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (hxid.equals(
                LocalUserInfo.getInstance(getApplicationContext()).getUserInfo("hxid"))) {
              Toast.makeText(getApplicationContext(), "不能和自己聊天。。", Toast.LENGTH_SHORT).show();
              return;
            }
            Intent intent = new Intent();
            intent.putExtra("userId", hxid);

            intent.putExtra("userNick", nick);
            intent.putExtra("userAvatar", avatar);
            intent.setClass(UserInfoActivity.this, ChatActivity.class);
            startActivity(intent);
          }
        });
    refresh();
  }