Пример #1
0
  public Bitmap getGroupChatContactAvatar(NmsGroupChatContact groupChatContact) {
    if (groupChatContact == null) {
      NmsLog.error(TAG, "groupChatContact is invalid!");
      return null;
    }

    ArrayList<Bitmap> bitmapList = new ArrayList<Bitmap>();

    short[] memberIds = groupChatContact.getMemberIds();

    if (memberIds != null) {
      for (int index = 0; index < memberIds.length && bitmapList.size() < 3; ++index) {
        Bitmap avatar = getAvatarViaEngineContactId(memberIds[index]);
        if (avatar != null) {
          bitmapList.add(avatar);
        }
      }
    } else {
      NmsLog.warn(TAG, "memberIds is null.");
    }

    if (bitmapList.size() < 3 && groupChatContact.isAlive()) {
      // myself bitmap
      Bitmap avatar = getMyselfAvatarViaSimId(groupChatContact.getSimId());
      if (avatar == null) {
        avatar = mDefaultBitmap;
      }
      bitmapList.add(avatar);
    }

    bitmapList =
        fillBitmapList(groupChatContact.getMemberCount(), bitmapList, mDefaultBitmap, mBlankBitmap);

    Bitmap result = null;
    if (bitmapList != null && bitmapList.size() == 3) {
      result = NmsCommonUtils.stitchBitmap(bitmapList.get(0), bitmapList.get(1), bitmapList.get(2));
    }

    return result;
  }
  private void initQuickGroupCard() {
    setContentView(R.layout.quick_group_contact);

    NmsGroupChatContact groupContact = (NmsGroupChatContact) contact;
    short[] members = groupContact.getMemberIds();
    buildGroupMembers(members, groupContact.isAlive());

    TextView tvName = (TextView) this.findViewById(R.id.tv_name);
    tvName.setText(groupContact.getName());

    TextView tvCount = (TextView) this.findViewById(R.id.tv_count);
    tvCount.setText(String.valueOf(groupContact.getMemberCount()));

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

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            addGroupChatMembers();
          }
        });
    Button btnChat = (Button) this.findViewById(R.id.btn_chat);
    btnChat.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            chat();
          }
        });

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

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            chat();
          }
        });
    LinearLayout llWelcome = (LinearLayout) this.findViewById(R.id.ll_group);

    if (groupContact.isAlive() && isActive) {
      btnWelcome.setVisibility(View.GONE);
    } else {
      llWelcome.setVisibility(View.GONE);
      btnWelcome.setVisibility(View.VISIBLE);
    }

    GridView gv = (GridView) this.findViewById(R.id.gv_group_card);

    GroupListAdapter adapter = new GroupListAdapter(this);
    gv.setAdapter(adapter);

    gv.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            viewGroupChatInfo();
          }
        });
  }