public Integer getEmailType() { return getAsInteger(ContactsContract.CommonDataKinds.Email.TYPE); }
public Integer getAsInteger(String key) { return getAsInteger(key, null); }
public Integer getPhoneType() { return getAsInteger(ContactsContract.CommonDataKinds.Phone.TYPE); }
/** * Counts occurrences of the specified type in the supplied entry list. * * @return The count of occurrences of the type in the entry list. 0 if entries is * {@literal null} */ private static int getEntryCountByType(ArrayList<ValuesDelta> entries, String typeColumn, int type) { int count = 0; if (entries != null) { for (ValuesDelta entry : entries) { Integer typeInteger = entry.getAsInteger(typeColumn); if (typeInteger != null && typeInteger == type) { count++; } } } return count; }
/** * Checks if the data kind allows addition of another entry (e.g. Exchange only * supports two "work" phone numbers). If not, tries to switch to one of the * unused types. If successful, returns true. */ private static boolean adjustType( ValuesDelta entry, ArrayList<ValuesDelta> entries, DataKind kind) { if (kind.typeColumn == null || kind.typeList == null || kind.typeList.size() == 0) { return true; } Integer typeInteger = entry.getAsInteger(kind.typeColumn); int type = typeInteger != null ? typeInteger : kind.typeList.get(0).rawValue; if (isTypeAllowed(type, entries, kind)) { entry.put(kind.typeColumn, type); return true; } // Specified type is not allowed - choose the first available type that is allowed int size = kind.typeList.size(); for (int i = 0; i < size; i++) { EditType editType = kind.typeList.get(i); if (isTypeAllowed(editType.rawValue, entries, kind)) { entry.put(kind.typeColumn, editType.rawValue); return true; } } return false; }
final Integer oldType = entry.getAsInteger(COLUMN_FOR_TYPE); final Integer typeForNewAccount; if (!allowedTypes.contains(oldType)) {