use of com.vodafone360.people.engine.contactsync.ContactChange in project 360-Engine-for-Android by 360.
the class ContactChangeHelper method areChangesEqual.
public static boolean areChangesEqual(ContactChange a, ContactChange b, boolean compareAll) {
if (a.getKey() != b.getKey()) {
return false;
}
// just for convenience
final int key = a.getKey();
if (!VersionUtils.is2XPlatform() && key == ContactChange.KEY_VCARD_NAME) {
// Need to convert to raw string or else we can't compare them because of NAB 1.X limitations
final Name nameA = VCardHelper.getName(a.getValue());
final Name nameB = VCardHelper.getName(b.getValue());
final String nameAStr = nameA.toString();
final String nameBStr = nameB.toString();
if (!TextUtils.equals(nameAStr, nameBStr)) {
return false;
}
} else if (!VersionUtils.is2XPlatform() && key == ContactChange.KEY_VCARD_ADDRESS) {
// Need to convert to raw string or else we can't compare them because of NAB 1.X limitations
final PostalAddress addressA = VCardHelper.getPostalAddress(a.getValue());
final PostalAddress addressB = VCardHelper.getPostalAddress(b.getValue());
// Need to also remove \n's that were put there by .toString
final String addressAStr = addressA.toString().replaceAll("\n", "");
final String addressBStr = addressB.toString().replaceAll("\n", "");
if (!TextUtils.equals(addressAStr, addressBStr)) {
return false;
}
} else if (!VersionUtils.is2XPlatform() && key == ContactChange.KEY_VCARD_ORG) {
// Org on 1.X does not support department, need to NOT compare that
final Organisation orgA = VCardHelper.getOrg(a.getValue());
final Organisation orgB = VCardHelper.getOrg(b.getValue());
if (!TextUtils.equals(orgA.name, orgB.name)) {
return false;
}
} else if (!TextUtils.equals(a.getValue(), b.getValue())) {
return false;
}
switch(key) {
case ContactChange.KEY_VCARD_ORG:
case ContactChange.KEY_VCARD_TITLE:
case ContactChange.KEY_VCARD_PHONE:
case ContactChange.KEY_VCARD_EMAIL:
case ContactChange.KEY_VCARD_ADDRESS:
// NAB may have changed these fields to preferred even though they were inserted as not preferred!
final int flagsWithoutPreferredA = a.getFlags() & ~ContactChange.FLAG_PREFERRED;
final int flagsWithoutPreferredB = b.getFlags() & ~ContactChange.FLAG_PREFERRED;
if (flagsWithoutPreferredA != flagsWithoutPreferredB) {
return false;
}
break;
default:
if (a.getFlags() != b.getFlags()) {
return false;
}
break;
}
if (VersionUtils.is2XPlatform() && a.getFlags() != b.getFlags()) {
return false;
} else if (!VersionUtils.is2XPlatform()) {
}
if (compareAll) {
if (a.getType() != b.getType()) {
return false;
}
if (a.getInternalContactId() != b.getInternalContactId()) {
return false;
}
if (a.getInternalDetailId() != b.getInternalDetailId()) {
return false;
}
if (a.getBackendContactId() != b.getBackendContactId()) {
return false;
}
if (a.getBackendDetailId() != b.getBackendDetailId()) {
return false;
}
if (a.getNabContactId() != b.getNabContactId()) {
return false;
}
if (a.getNabDetailId() != b.getNabDetailId()) {
return false;
}
}
return true;
}
use of com.vodafone360.people.engine.contactsync.ContactChange in project 360-Engine-for-Android by 360.
the class ContactChangeHelper method generateRandomChangesForKey.
private static void generateRandomChangesForKey(List<ContactChange> ccList, int key, long internalContactId, long backendContactId, long nabContactId, int numChanges) {
boolean preferredSelected = false;
for (int i = 0; i < numChanges; i++) {
ContactChange cc = randomContactChange(key, internalContactId, backendContactId, nabContactId, !preferredSelected);
if (!preferredSelected) {
preferredSelected = (cc.getFlags() & ContactChange.FLAG_PREFERRED) == ContactChange.FLAG_PREFERRED;
}
ccList.add(cc);
}
}
use of com.vodafone360.people.engine.contactsync.ContactChange in project 360-Engine-for-Android by 360.
the class ContactChangeHelper method areChangeListsEqual.
public static boolean areChangeListsEqual(ContactChange[] a, ContactChange[] b, boolean compareAll) {
final int aLength = a.length;
final int bLength = b.length;
if (aLength != bLength) {
printContactChangeList(a);
printContactChangeList(b);
return false;
}
for (int i = 0; i < aLength; i++) {
final ContactChange ccA = a[i];
final ContactChange ccB = b[i];
if (!areChangesEqual(ccA, ccB, compareAll)) {
Log.e("CC COMPARISON", "Contact Change comparison mismatch, ContactChange A to follow:");
printContactChange(ccA);
Log.e("CC COMPARISON", "Contact Change comparison mismatch, ContactChange B to follow:");
printContactChange(ccB);
return false;
}
}
return true;
}
use of com.vodafone360.people.engine.contactsync.ContactChange in project 360-Engine-for-Android by 360.
the class ContactChangeHelper method printContactChangeList.
public static void printContactChangeList(ContactChange[] ccList) {
final int length = ccList.length;
Log.i("CCLIST", "############### START ###############");
for (int i = 0; i < length; i++) {
final ContactChange cc = ccList[i];
printContactChange(cc);
}
Log.i("CCLIST", "############### END ###############");
}
use of com.vodafone360.people.engine.contactsync.ContactChange in project 360-Engine-for-Android by 360.
the class ContactChangeHelper method randomContactChange.
private static ContactChange randomContactChange(int key, long internalContactId, long backendContactId, long nabContactId, boolean allowPreferred) {
ContactChange cc = randomContactChange(key, allowPreferred);
cc.setInternalContactId(internalContactId);
cc.setBackendContactId(backendContactId);
cc.setNabContactId(nabContactId);
return cc;
}
Aggregations