public void buildGroupMembers(short[] contactId, boolean isAlive) {
    memberList.clear();

    if (isAlive) {
      NmsContact selfPerson = new NmsContact();
      selfPerson.setName(
          this.getResources().getText(R.string.STR_NMS_GROUP_MEMEBER_YOU).toString());
      selfPerson.setId(
          NmsContactApi.getInstance(mContext)
              .getMyselfEngineContactIdViaSimId(
                  (int) NmsPlatformAdapter.getInstance(mContext).getCurrentSimId()));

      memberList.add(selfPerson);
    }

    if (contactId != null) {
      for (short id : contactId) {
        NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(id);
        if (contact != null) {
          memberList.add(contact);
        } else {
          NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
        }
      }
    }
  }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ViewGroupHolder viewholder = null;
      if (convertView == null) {
        viewholder = new ViewGroupHolder();

        final LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.quick_group_contact_item, null);

        viewholder.imageUser = (ImageView) convertView.findViewById(R.id.iv_contact);
        viewholder.tvName = (TextView) convertView.findViewById(R.id.tv_name);

        convertView.setTag(viewholder);
      } else {
        viewholder = (ViewGroupHolder) convertView.getTag();
      }

      NmsContact c = memberList.get(position);

      if (c != null) {
        viewholder.tvName.setText(c.getName());
        mImageWorker.loadImage(c.getId(), viewholder.imageUser);
      }

      return convertView;
    }
示例#3
0
 public NmsUIContact getContactInfoViaEngineContactId(short engineContactId) {
   NmsUIContact contact = new NmsUIContact();
   NmsContact tmp = engineadapter.get().nmsUIGetContact(engineContactId);
   contact.setEngineContactId(engineContactId);
   contact.setSystemContactId(engineContactId);
   contact.setType(NmsContactType.HISSAGE_USER);
   contact.setName(tmp.getName());
   contact.setNumberOrEmail(tmp.getNumber());
   return contact;
 }
  public HashSet<String> getSelectedContact() {
    HashSet<String> s = new HashSet<String>();

    for (NmsContact c : memberList) {
      if (c.getId() > 0) {
        s.add(String.valueOf(c.getId()));
      }
    }

    return s;
  }
  public void selectGroupMembers(String[] contactId) {
    List<String> members = new ArrayList<String>();
    NmsGroupChatContact groupContact = (NmsGroupChatContact) contact;
    short groupId = groupContact.getId();
    if (contactId != null) {
      NmsLog.trace(Tag, "Add group members to group chat, the groupId:" + groupId);
      if (groupId > 0) {
        for (String id : contactId) {
          short engineContactId = Short.valueOf(id);
          NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
          if (contact != null) {
            members.add(contact.getNumber());
          } else {
            NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
          }
        }

        boolean ret = NmsIpMessageApiNative.nmsAddMembersToGroup(groupId, members);
        if (ret) {
          for (String id : contactId) {
            short engineContactId = Short.valueOf(id);
            NmsContact contact =
                NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
            if (contact != null) {
              memberList.add(contact);
            } else {
              NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
            }
          }
          Toast.makeText(mContext, R.string.STR_NMS_ADD_GROUP_MEMBER_SUCCESS, Toast.LENGTH_SHORT)
              .show();
        } else {
          Toast.makeText(mContext, R.string.STR_NMS_ADD_GROUP_MEMBER_FAILED, Toast.LENGTH_SHORT)
              .show();
        }
      } else {
        for (String id : contactId) {
          short engineContactId = Short.valueOf(id);
          NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
          if (contact != null) {
            memberList.add(contact);
          } else {
            NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
          }
        }
      }
    }

    // if (GroupChatMode.VIEW == groupChatMode) {
    // buildViewGroupMembers();
    // }
  }
 private void chat() {
   finish();
   Intent intent = new Intent(this, NmsChatDetailsActivity.class);
   intent.putExtra(NmsIpMessageConsts.NMS_ENGINE_CONTACT_ID, contact.getId());
   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   startActivity(intent);
 }
示例#7
0
  public Bitmap getAvatarViaEngineContactId(short engineContactId) {
    if (engineContactId <= 0) {
      NmsLog.error(TAG, "getAvatarViaEngineContactId. engineContactId <= 0");
      return null;
    }

    Bitmap result = null;

    NmsContact contact = engineadapter.get().nmsUIGetContact(engineContactId);
    if (contact != null) {
      if (contact instanceof NmsGroupChatContact) {
        result = getGroupChatContactAvatar((NmsGroupChatContact) contact);
      } else if (contact instanceof NmsBroadCastContact) {
        result = mBroadCastBitmap;
      } else {
        result = getSystemAvatarViaNumber(contact.getNumber());
        if (result == null) {
          result = getEngineAvatarViaEngineContactId(contact.getId());
        }
      }
    }

    return result;
  }
示例#8
0
  public Bitmap getEngineAvatarViaEngineContactId(short engineContactId) {
    if (engineContactId <= 0) {
      NmsLog.error(TAG, "getEngineAvatarViaEngineContactId. engineContactId is invalid!");
      return null;
    }

    Bitmap result = null;

    if (isMyselfEngineContactId(engineContactId)) {
      NmsContact contact = engineadapter.get().nmsUIGetContact(engineContactId);
      NmsProfileSettings userProfile =
          engineadapter
              .get()
              .nmsUIGetUserInfoViaImsi(
                  engineadapter.get().nmsUIGetImsiViaNumber(contact.getNumber()));
      if (userProfile != null) {
        result = userProfile.getProfileSettingsAvatar();
      }
    } else {
      SNmsImg photoPath = engineadapter.get().nmsUIGetContactImg(engineContactId);
      if (photoPath != null) {
        if (photoPath.imgPath != null) {
          try {
            result = BitmapFactory.decodeFile(photoPath.imgPath);
          } catch (Exception e) {
            NmsLog.warn(
                TAG, "BitmapFactory.decodeFile failed, engineContactId: " + engineContactId);
          }
        } else if (photoPath.byteImg != null) {
          result = BitmapFactory.decodeByteArray(photoPath.byteImg, 0, photoPath.byteImg.length);
        }
      }
    }

    return result;
  }
  private void updateUI() {

    setContentView(R.layout.quick_contact);
    ImageView ivAvatar = (ImageView) this.findViewById(R.id.iv_avatar);

    if (contact != null) {
      Bitmap bitmap =
          NmsContactApi.getInstance(mContext).getAvatarViaEngineContactId(contact.getId());
      if (bitmap != null) {
        ivAvatar.setImageBitmap(bitmap);
      }
    }

    TextView tvName = (TextView) this.findViewById(R.id.tv_name);
    tvName.setText(nativeContact.name);

    ListView lvPhone = (ListView) this.findViewById(R.id.lv_phonelist);

    LayoutParams lp = (LayoutParams) lvPhone.getLayoutParams();
    if (nativeContact.numbers.size() > 2) {
      lp.height = this.getResources().getDimensionPixelOffset(R.dimen.phone_list_quick);
    }

    lvPhone.setLayoutParams(lp);

    PhoneListAdapter adapter = new PhoneListAdapter(this);
    lvPhone.setAdapter(adapter);

    lvPhone.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            call(nativeContact.numbers.get(arg2).number);
          }
        });
  }
 private void leaveGroup() {
   MessageUtils.showLeaveGroupDialog(this, contact.getId(), true);
 }