コード例 #1
0
  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();
    // }
  }
コード例 #2
0
  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);
        }
      }
    }
  }
コード例 #3
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    mContext = this; // this.getApplicationContext();
    threadId = getIntent().getLongExtra("threadId", (long) -1);
    contactId = getIntent().getShortExtra("contactId", (short) -1);
    phoneNum = getIntent().getStringExtra("PHONE_NUM");

    int simId = (int) NmsPlatformAdapter.getInstance(this).getCurrentSimId();
    SNmsSimInfo info = NmsIpMessageApiNative.nmsGetSimInfoViaSimId(simId);
    if (info != null && info.status != NmsSimActivateStatus.NMS_SIM_STATUS_ACTIVATED) {
      isActive = false;
    }

    if (threadId > 0) {
      contact = NmsIpMessageApiNative.nmsGetContactInfoViaThreadId(threadId);
    } else {
      if (contactId > 0) {
        contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(contactId);
      } else {
        contact = NmsIpMessageApiNative.nmsGetContactInfoViaNumber(phoneNum);
      }
    }

    try {
      if (contact instanceof NmsGroupChatContact) {
        if (simId != ((NmsGroupChatContact) contact).getSimId()) {
          isActive = false;
        }

        initQuickGroupCard();
      } else {
        initQuickContactCard();
      }
    } catch (Exception e) {
      NmsLog.error(Tag, "onCreate got the execption: " + NmsLog.nmsGetStactTrace(e));
    }
  }