public boolean isVisible() { return getValues().isVisible(); }
public Long getRawContactId() { return getValues().getAsLong(RawContacts._ID); }
/** * Search all contained {@link RawContactDelta} for the first one with an * existing {@link RawContacts#_ID} value. Usually used when creating * {@link AggregationExceptions} during an update. */ public long findRawContactId() { for (RawContactDelta delta : this) { final Long rawContactId = delta.getValues().getAsLong(RawContacts._ID); if (rawContactId != null && rawContactId >= 0) { return rawContactId; } } return -1; }
public String getDataSet() { return getValues().getAsString(RawContacts.DATA_SET); }
public String getAccountName() { return getValues().getAsString(RawContacts.ACCOUNT_NAME); }
public String getAccountType() { return getValues().getAsString(RawContacts.ACCOUNT_TYPE); }
/** * Find {@link RawContacts#_ID} of the requested {@link RawContactDelta}. */ public Long getRawContactId(int index) { if (index >= 0 && index < this.size()) { final RawContactDelta delta = this.get(index); final ValuesDelta values = delta.getValues(); if (values.isVisible()) { return values.getAsLong(RawContacts._ID); } } return null; }
/** * Processing to trim any empty {@link ValuesDelta} and {@link RawContactDelta} * from the given {@link RawContactDeltaList}, assuming the given {@link AccountTypeManager} * dictates the structure for various fields. This method ignores rows not * described by the {@link AccountType}. */ public static void trimEmpty(RawContactDeltaList set, AccountTypeManager accountTypes) { for (RawContactDelta state : set) { ValuesDelta values = state.getValues(); final String accountType = values.getAsString(RawContacts.ACCOUNT_TYPE); final String dataSet = values.getAsString(RawContacts.DATA_SET); final AccountType type = accountTypes.getAccountType(accountType, dataSet); trimEmpty(state, type); } }
/** * Return the AccountType that this raw-contact belongs to. */ public AccountType getRawContactAccountType(Context context) { ContentValues entityValues = getValues().getCompleteValues(); String type = entityValues.getAsString(RawContacts.ACCOUNT_TYPE); String dataSet = entityValues.getAsString(RawContacts.DATA_SET); return AccountTypeManager.getInstance(context).getAccountType(type, dataSet); }
/** * Merge the "after" values from the given {@link RawContactDeltaList}, discarding any * previous "after" states. This is typically used when re-parenting user * edits onto an updated {@link RawContactDeltaList}. */ public static RawContactDeltaList mergeAfter(RawContactDeltaList local, RawContactDeltaList remote) { if (local == null) local = new RawContactDeltaList(); // For each entity in the remote set, try matching over existing for (RawContactDelta remoteEntity : remote) { final Long rawContactId = remoteEntity.getValues().getId(); // Find or create local match and merge final RawContactDelta localEntity = local.getByRawContactId(rawContactId); final RawContactDelta merged = RawContactDelta.mergeAfter(localEntity, remoteEntity); if (localEntity == null && merged != null) { // No local entry before, so insert local.add(merged); } } return local; }
public static boolean hasChanges(RawContactDeltaList set, AccountTypeManager accountTypes, Set<String> excludedMimeTypes) { if (set.isMarkedForSplitting() || set.isMarkedForJoining()) { return true; } for (RawContactDelta state : set) { ValuesDelta values = state.getValues(); final String accountType = values.getAsString(RawContacts.ACCOUNT_TYPE); final String dataSet = values.getAsString(RawContacts.DATA_SET); final AccountType type = accountTypes.getAccountType(accountType, dataSet); if (hasChanges(state, type, excludedMimeTypes)) { return true; } } return false; }
private Builder buildSplitContactDiffHelper(int index1, int index2, int[] backRefs) { final Builder builder = ContentProviderOperation.newUpdate(AggregationExceptions.CONTENT_URI); builder.withValue(AggregationExceptions.TYPE, AggregationExceptions.TYPE_KEEP_SEPARATE); Long rawContactId1 = get(index1).getValues().getAsLong(RawContacts._ID); int backRef1 = backRefs[index1]; if (rawContactId1 != null && rawContactId1 >= 0) { builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, rawContactId1); } else if (backRef1 >= 0) { builder.withValueBackReference(AggregationExceptions.RAW_CONTACT_ID1, backRef1); } else { return null; } Long rawContactId2 = get(index2).getValues().getAsLong(RawContacts._ID); int backRef2 = backRefs[index2]; if (rawContactId2 != null && rawContactId2 >= 0) { builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, rawContactId2); } else if (backRef2 >= 0) { builder.withValueBackReference(AggregationExceptions.RAW_CONTACT_ID2, backRef2); } else { return null; } return builder; }
state.getValues().getAsString(RawContacts.ACCOUNT_TYPE)); final boolean isPhoto = TextUtils.equals(Photo.CONTENT_ITEM_TYPE, kind.mimeType); final boolean isGooglePhoto = isPhoto && isGoogleAccount;