예제 #1
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = null;
      ViewHolder mViewHolder = null;
      if (convertView == null || convertView.getTag() == null) {
        view = View.inflate(mContext, R.layout.group_item, null);

        mViewHolder = new ViewHolder();
        mViewHolder.groupitem_avatar_iv = (ImageView) view.findViewById(R.id.groupitem_avatar_iv);
        mViewHolder.group_name = (EmojiconTextView) view.findViewById(R.id.group_name);
        mViewHolder.group_id = (TextView) view.findViewById(R.id.group_id);
        mViewHolder.join_state = (TextView) view.findViewById(R.id.join_state);
        view.setTag(mViewHolder);
      } else {
        view = convertView;
        mViewHolder = (ViewHolder) view.getTag();
      }

      DemoGroup group = getItem(position);
      if (group != null) {
        Bitmap bitmap = ContactLogic.getChatroomPhoto(group.getGroupId());
        if (bitmap != null) {
          mViewHolder.groupitem_avatar_iv.setImageBitmap(bitmap);
          mViewHolder.groupitem_avatar_iv.setPadding(padding, padding, padding, padding);

        } else {
          mViewHolder.groupitem_avatar_iv.setImageResource(R.drawable.group_head);
          mViewHolder.groupitem_avatar_iv.setPadding(0, 0, 0, 0);
        }
        mViewHolder.group_name.setText(
            TextUtils.isEmpty(group.getName()) ? group.getGroupId() : group.getName());
        mViewHolder.group_id.setText(
            getString(R.string.str_group_id_fmt, DemoUtils.getGroupShortId(group.getGroupId())));
        mViewHolder.join_state.setText(group.isJoin() ? "已加入" : "");
        mViewHolder.join_state.setVisibility(group.isJoin() ? View.VISIBLE : View.GONE);
      }

      return view;
    }
예제 #2
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   if (mGroupAdapter != null) {
     DemoGroup dGroup = mGroupAdapter.getItem(position);
     if (dGroup.isJoin()) {
       CCPAppManager.startChattingAction(
           getActivity(), dGroup.getGroupId(), dGroup.getName());
       return;
     }
     Intent intent = new Intent(getActivity(), ApplyWithGroupPermissionActivity.class);
     intent.putExtra(GroupInfoActivity.GROUP_ID, dGroup.getGroupId());
     startActivity(intent);
   }
 }