コード例 #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
  private void setQuickContactCursor(Cursor cursor) {

    if (cursor != null && cursor.moveToFirst()) {
      nativeContact = new QuickContactDetail();
      // contact.contactId = contactId;
      nativeContact.numbers = new ArrayList<NmsQuickContactActivity.QuickContactPhone>();
      do {
        String mimeType = cursor.getString(cursor.getColumnIndex(Data.MIMETYPE));
        if (mimeType.equals(StructuredName.CONTENT_ITEM_TYPE)) {
          String name = cursor.getString(cursor.getColumnIndex(StructuredName.DISPLAY_NAME));
          nativeContact.name = name;
        } else if (mimeType.equals(Phone.CONTENT_ITEM_TYPE)) {
          boolean isAdd = true;
          String number = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
          if (number == null) {
            continue;
          }
          for (int i = 0; i < nativeContact.numbers.size(); ++i) {
            if (number.equals(nativeContact.numbers.get(i).number)) {
              isAdd = false;
              break;
            }
          }
          if (!isAdd) {
            continue;
          }
          QuickContactPhone phone = new QuickContactPhone();
          phone.number = number;
          String lable =
              Phone.getTypeLabel(
                      getResources(),
                      cursor.getInt(cursor.getColumnIndex(Phone.TYPE)),
                      cursor.getString(cursor.getColumnIndex(Phone.LABEL)))
                  .toString();
          phone.isHissage = NmsIpMessageApiNative.nmsIsiSMSNumber(number);
          if (phone.isHissage) {
            phone.numberType = lable + this.getText(R.string.STR_NMS_ISMS_ENABLE).toString();
          } else {
            phone.numberType = lable;
          }

          nativeContact.numbers.add(phone);
        } else if (mimeType.equals(Photo.CONTENT_ITEM_TYPE)) {
          byte[] photoBytes = cursor.getBlob(cursor.getColumnIndex(Photo.PHOTO));
          if (photoBytes != null) {
            nativeContact.avatar = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length);
          }
        }
      } while (cursor.moveToNext());
    }
    if (cursor != null) {
      cursor.close();
    }

    updateUI();
  }
コード例 #4
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));
    }
  }