diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/android/AbstractPhoneContact.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/android/AbstractPhoneContact.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/android/AbstractPhoneContact.java b/src/main/java/de/pixart/messenger/android/AbstractPhoneContact.java new file mode 100644 index 000000000..32dbfa77e --- /dev/null +++ b/src/main/java/de/pixart/messenger/android/AbstractPhoneContact.java @@ -0,0 +1,39 @@ +package de.pixart.messenger.android; + +import android.database.Cursor; +import android.net.Uri; +import android.provider.ContactsContract; +import android.text.TextUtils; + +public abstract class AbstractPhoneContact { + + private final Uri lookupUri; + private final String displayName; + private final String photoUri; + + + AbstractPhoneContact(Cursor cursor) { + int phoneId = cursor.getInt(cursor.getColumnIndex(ContactsContract.Data._ID)); + String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.LOOKUP_KEY)); + this.lookupUri = ContactsContract.Contacts.getLookupUri(phoneId, lookupKey); + this.displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); + this.photoUri = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.PHOTO_URI)); + } + + public Uri getLookupUri() { + return lookupUri; + } + + public String getDisplayName() { + return displayName; + } + + public String getPhotoUri() { + return photoUri; + } + + + public int rating() { + return (TextUtils.isEmpty(displayName) ? 0 : 2) + (TextUtils.isEmpty(photoUri) ? 0 : 1); + } +}
\ No newline at end of file |