@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ContactInfo other = (ContactInfo) obj; if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false; if (!TextUtils.equals(name, other.name)) return false; if (type != other.type) return false; if (!TextUtils.equals(label, other.label)) return false; if (!TextUtils.equals(number, other.number)) return false; if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false; if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; if (photoId != other.photoId) return false; if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; if (!TextUtils.equals(objectId, other.objectId)) return false; return true; }
@Override public Contact loadInBackground() { try { final ContentResolver resolver = getContext().getContentResolver(); final Uri uriCurrentFormat = ContactLoaderUtils.ensureIsContactUri(resolver, mLookupUri); final Contact cachedResult = sCachedResult; sCachedResult = null; // Is this the same Uri as what we had before already? In that case, reuse that result final Contact result; final boolean resultIsCached; if (cachedResult != null && UriUtils.areEqual(cachedResult.getLookupUri(), mLookupUri)) { // We are using a cached result from earlier. Below, we should make sure // we are not doing any more network or disc accesses result = new Contact(mRequestedUri, cachedResult); resultIsCached = true; } else { if (uriCurrentFormat.getLastPathSegment().equals(Constants.LOOKUP_URI_ENCODED)) { result = loadEncodedContactEntity(uriCurrentFormat); } else { result = loadContactEntity(resolver, uriCurrentFormat); } resultIsCached = false; } if (result.isLoaded()) { if (result.isDirectoryEntry()) { if (!resultIsCached) { loadDirectoryMetaData(result); } } else if (mLoadGroupMetaData) { if (result.getGroupMetaData() == null) { loadGroupMetaData(result); } } if (mComputeFormattedPhoneNumber) { computeFormattedPhoneNumbers(result); } if (!resultIsCached) loadPhotoBinaryData(result); // Note ME profile should never have "Add connection" if (mLoadInvitableAccountTypes && result.getInvitableAccountTypes() == null) { loadInvitableAccountTypes(result); } } return result; } catch (Exception e) { Log.e(TAG, "Error loading the contact: " + mLookupUri, e); return Contact.forError(mRequestedUri, e); } }