/** * Find the raw-contact (an {@link RawContactDelta}) with the specified ID. */ public RawContactDelta getByRawContactId(Long rawContactId) { final int index = this.indexOfRawContactId(rawContactId); return (index == -1) ? null : this.get(index); }
/** Return the first RawContactDelta corresponding to a writable raw-contact, or null. */ public RawContactDelta getFirstWritableRawContact(Context context) { final int index = indexOfFirstWritableRawContact(context); return (index == -1) ? null : get(index); }
/** * 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; }
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; }