Search in sources :

Example 1 with StructuredName

use of android.provider.ContactsContract.CommonDataKinds.StructuredName in project 360-Engine-for-Android by 360.

the class NativeContactsApi2 method readName.

/**
     * Reads an name detail as a {@link ContactChange} from the provided cursor.
     * For this type of detail we need to use a VCARD (semicolon separated)
     * value.
     * 
     * @param cursor Cursor to read from
     * @param ccList List of Contact Changes to add read detail data
     * @param nabContactId ID of the NAB Contact
     */
private void readName(Cursor cursor, List<ContactChange> ccList, long nabContactId) {
    // Using display name only to check if there is a valid name to read
    final String displayName = CursorUtils.getString(cursor, StructuredName.DISPLAY_NAME);
    if (!TextUtils.isEmpty(displayName)) {
        final long nabDetailId = CursorUtils.getLong(cursor, StructuredName._ID);
        // VCard Helper data type (CAB)
        final Name name = new Name();
        // NAB: Given name -> CAB: First name
        name.firstname = CursorUtils.getString(cursor, StructuredName.GIVEN_NAME);
        // NAB: Family name -> CAB: Surname
        name.surname = CursorUtils.getString(cursor, StructuredName.FAMILY_NAME);
        // NAB: Prefix -> CAB: Title
        name.title = CursorUtils.getString(cursor, StructuredName.PREFIX);
        // NAB: Middle name -> CAB: Middle name
        name.midname = CursorUtils.getString(cursor, StructuredName.MIDDLE_NAME);
        // NAB: Suffix -> CAB: Suffixes
        name.suffixes = CursorUtils.getString(cursor, StructuredName.SUFFIX);
        // NOTE: Ignoring Phonetics (DATA7, DATA8 and DATA9)!
        // TODO: Need to get middle name and concatenate into value
        final ContactChange cc = new ContactChange(ContactChange.KEY_VCARD_NAME, VCardHelper.makeName(name), ContactChange.FLAG_NONE);
        cc.setNabContactId(nabContactId);
        cc.setNabDetailId(nabDetailId);
        ccList.add(cc);
    }
}
Also used : StructuredName(android.provider.ContactsContract.CommonDataKinds.StructuredName) Name(com.vodafone360.people.datatypes.VCardHelper.Name)

Aggregations

StructuredName (android.provider.ContactsContract.CommonDataKinds.StructuredName)1 Name (com.vodafone360.people.datatypes.VCardHelper.Name)1