flip addresses and events at the Contact model
This commit is contained in:
parent
d3498f96cb
commit
835d7bfde6
|
@ -52,13 +52,13 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
val photoUri = cursor.getStringValue(CommonDataKinds.StructuredName.PHOTO_URI) ?: ""
|
||||
val number = ArrayList<PhoneNumber>() // proper value is obtained below
|
||||
val emails = ArrayList<Email>()
|
||||
val events = ArrayList<Event>()
|
||||
val addresses = ArrayList<Address>()
|
||||
val events = ArrayList<Event>()
|
||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: ""
|
||||
val starred = cursor.getIntValue(CommonDataKinds.StructuredName.STARRED)
|
||||
val contactId = cursor.getIntValue(ContactsContract.Data.CONTACT_ID)
|
||||
val thumbnailUri = cursor.getStringValue(CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI) ?: ""
|
||||
val contact = Contact(id, firstName, middleName, surname, photoUri, number, emails, events, addresses, accountName,
|
||||
val contact = Contact(id, firstName, middleName, surname, photoUri, number, emails, addresses, events, accountName,
|
||||
starred, contactId, thumbnailUri, null)
|
||||
contacts.put(id, contact)
|
||||
} while (cursor.moveToNext())
|
||||
|
@ -269,13 +269,13 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
val photoUri = cursor.getStringValue(CommonDataKinds.Phone.PHOTO_URI) ?: ""
|
||||
val number = getPhoneNumbers(id)[id] ?: ArrayList()
|
||||
val emails = getEmails(id)[id] ?: ArrayList()
|
||||
val events = getEvents(id)[id] ?: ArrayList()
|
||||
val addresses = getAddresses(id)[id] ?: ArrayList()
|
||||
val events = getEvents(id)[id] ?: ArrayList()
|
||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: ""
|
||||
val starred = cursor.getIntValue(CommonDataKinds.StructuredName.STARRED)
|
||||
val contactId = cursor.getIntValue(ContactsContract.Data.CONTACT_ID)
|
||||
val thumbnailUri = cursor.getStringValue(CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI) ?: ""
|
||||
return Contact(id, firstName, middleName, surname, photoUri, number, emails, events, addresses, accountName, starred, contactId, thumbnailUri, null)
|
||||
return Contact(id, firstName, middleName, surname, photoUri, number, emails, addresses, events, accountName, starred, contactId, thumbnailUri, null)
|
||||
}
|
||||
} finally {
|
||||
cursor?.close()
|
||||
|
|
|
@ -137,12 +137,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
val emailsToken = object : TypeToken<List<Email>>() {}.type
|
||||
val emails = Gson().fromJson<ArrayList<Email>>(emailsJson, emailsToken) ?: ArrayList(1)
|
||||
|
||||
val addresses = ArrayList<Address>()
|
||||
|
||||
val eventsJson = cursor.getStringValue(COL_EVENTS)
|
||||
val eventsToken = object : TypeToken<List<Event>>() {}.type
|
||||
val events = Gson().fromJson<ArrayList<Event>>(eventsJson, eventsToken) ?: ArrayList(1)
|
||||
|
||||
val addresses = ArrayList<Address>()
|
||||
|
||||
val photoByteArray = cursor.getBlobValue(COL_PHOTO) ?: null
|
||||
val photo = if (photoByteArray?.isNotEmpty() == true) {
|
||||
BitmapFactory.decodeByteArray(photoByteArray, 0, photoByteArray.size)
|
||||
|
@ -151,7 +151,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
}
|
||||
|
||||
val starred = cursor.getIntValue(COL_STARRED)
|
||||
val contact = Contact(id, firstName, middleName, surname, "", phoneNumbers, emails, events, addresses, SMT_PRIVATE, starred, id, "", photo)
|
||||
val contact = Contact(id, firstName, middleName, surname, "", phoneNumbers, emails, addresses, events, SMT_PRIVATE, starred, id, "", photo)
|
||||
contacts.add(contact)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||
}
|
||||
|
||||
private fun saveContact(source: String) {
|
||||
val contact = Contact(0, curFirstName, curMiddleName, curSurname, curPhotoUri, curPhoneNumbers, curEmails, curEvents, curAddresses, source, 0, 0, "", null)
|
||||
val contact = Contact(0, curFirstName, curMiddleName, curSurname, curPhotoUri, curPhoneNumbers, curEmails, curAddresses, curEvents, source, 0, 0, "", null)
|
||||
if (ContactsHelper(activity).insertContact(contact)) {
|
||||
contactsImported++
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_MIDDLE_NAME
|
|||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||
|
||||
data class Contact(val id: Int, var firstName: String, var middleName: String, var surname: String, var photoUri: String,
|
||||
var phoneNumbers: ArrayList<PhoneNumber>, var emails: ArrayList<Email>, var events: ArrayList<Event>, var addresses: ArrayList<Address>,
|
||||
var phoneNumbers: ArrayList<PhoneNumber>, var emails: ArrayList<Email>, var addresses: ArrayList<Address>, var events: ArrayList<Event>,
|
||||
var source: String, var starred: Int, val contactId: Int, val thumbnailUri: String, var photo: Bitmap?) : Comparable<Contact> {
|
||||
companion object {
|
||||
var sorting = 0
|
||||
|
|
Loading…
Reference in New Issue