mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fill the list of contacts at insert_or_edit
This commit is contained in:
@ -9,8 +9,12 @@ import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.helpers.KEY_PHONE
|
||||
import com.simplemobiletools.contacts.helpers.LOCATION_INSERT_OR_EDIT
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
||||
|
||||
class InsertOrEditContactActivity : SimpleActivity() {
|
||||
@ -22,6 +26,9 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
||||
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
// we do not really care about the permission request result. Even if it was denied, load private contacts
|
||||
ContactsHelper(this).getContacts {
|
||||
gotContacts(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,4 +50,23 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
||||
|
||||
existing_contact_label.setTextColor(getAdjustedPrimaryColor())
|
||||
}
|
||||
|
||||
private fun gotContacts(contacts: ArrayList<Contact>) {
|
||||
Contact.sorting = config.sorting
|
||||
Contact.startWithSurname = config.startNameWithSurname
|
||||
contacts.sort()
|
||||
|
||||
ContactsAdapter(this, contacts, null, LOCATION_INSERT_OR_EDIT, null, existing_contact_list, existing_contact_fastscroller) {
|
||||
|
||||
}.apply {
|
||||
addVerticalDividers(true)
|
||||
existing_contact_list.adapter = this
|
||||
}
|
||||
|
||||
existing_contact_fastscroller.setScrollToY(0)
|
||||
existing_contact_fastscroller.setViews(existing_contact_list) {
|
||||
val item = (existing_contact_list.adapter as ContactsAdapter).contactItems.getOrNull(it)
|
||||
existing_contact_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
||||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val contact = contactItems[position]
|
||||
val view = holder.bindView(contact, true, true) { itemView, layoutPosition ->
|
||||
val allowLongClick = location != LOCATION_INSERT_OR_EDIT
|
||||
val view = holder.bindView(contact, true, allowLongClick) { itemView, layoutPosition ->
|
||||
setupView(itemView, contact)
|
||||
}
|
||||
bindViewHolder(holder, position, view)
|
||||
|
@ -34,6 +34,7 @@ const val LOCATION_RECENTS_TAB = 2
|
||||
const val LOCATION_GROUPS_TAB = 3
|
||||
const val LOCATION_GROUP_CONTACTS = 4
|
||||
const val LOCATION_DIALPAD = 5
|
||||
const val LOCATION_INSERT_OR_EDIT = 6
|
||||
|
||||
const val CONTACTS_TAB_MASK = 1
|
||||
const val FAVORITES_TAB_MASK = 2
|
||||
|
Reference in New Issue
Block a user