Esempio n. 1
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 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();
    // }
  }
Esempio n. 3
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;
  }
Esempio n. 4
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;
  }