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