mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
refresh GroupContactsActivity on resume
This commit is contained in:
@ -29,7 +29,6 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener {
|
|||||||
group = intent.extras.getSerializable(GROUP) as Group
|
group = intent.extras.getSerializable(GROUP) as Group
|
||||||
supportActionBar?.title = group.title
|
supportActionBar?.title = group.title
|
||||||
|
|
||||||
refreshContacts()
|
|
||||||
group_contacts_fab.setOnClickListener {
|
group_contacts_fab.setOnClickListener {
|
||||||
SelectContactsDialog(this, allContacts, groupContacts) { addedContacts, removedContacts ->
|
SelectContactsDialog(this, allContacts, groupContacts) { addedContacts, removedContacts ->
|
||||||
ContactsHelper(this).apply {
|
ContactsHelper(this).apply {
|
||||||
@ -41,6 +40,11 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
refreshContacts()
|
||||||
|
}
|
||||||
|
|
||||||
private fun refreshContacts() {
|
private fun refreshContacts() {
|
||||||
ContactsHelper(this).getContacts {
|
ContactsHelper(this).getContacts {
|
||||||
allContacts = it
|
allContacts = it
|
||||||
@ -54,29 +58,34 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateContacts(contacts: ArrayList<Contact>) {
|
private fun updateContacts(contacts: ArrayList<Contact>) {
|
||||||
ContactsAdapter(this, contacts, null, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) {
|
val currAdapter = group_contacts_list.adapter
|
||||||
when (config.onContactClick) {
|
if (currAdapter == null) {
|
||||||
ON_CLICK_CALL_CONTACT -> {
|
ContactsAdapter(this, contacts, null, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) {
|
||||||
val contact = it as Contact
|
when (config.onContactClick) {
|
||||||
if (contact.phoneNumbers.isNotEmpty()) {
|
ON_CLICK_CALL_CONTACT -> {
|
||||||
tryStartCall(it)
|
val contact = it as Contact
|
||||||
} else {
|
if (contact.phoneNumbers.isNotEmpty()) {
|
||||||
toast(R.string.no_phone_number_found)
|
tryStartCall(it)
|
||||||
|
} else {
|
||||||
|
toast(R.string.no_phone_number_found)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ON_CLICK_VIEW_CONTACT -> viewContact(it as Contact)
|
||||||
|
ON_CLICK_EDIT_CONTACT -> editContact(it as Contact)
|
||||||
}
|
}
|
||||||
ON_CLICK_VIEW_CONTACT -> viewContact(it as Contact)
|
}.apply {
|
||||||
ON_CLICK_EDIT_CONTACT -> editContact(it as Contact)
|
setupDragListener(true)
|
||||||
|
addVerticalDividers(true)
|
||||||
|
group_contacts_list.adapter = this
|
||||||
}
|
}
|
||||||
}.apply {
|
|
||||||
setupDragListener(true)
|
|
||||||
addVerticalDividers(true)
|
|
||||||
group_contacts_list.adapter = this
|
|
||||||
}
|
|
||||||
|
|
||||||
group_contacts_fastscroller.setScrollTo(0)
|
group_contacts_fastscroller.setScrollTo(0)
|
||||||
group_contacts_fastscroller.setViews(group_contacts_list) {
|
group_contacts_fastscroller.setViews(group_contacts_list) {
|
||||||
val item = (group_contacts_list.adapter as ContactsAdapter).contactItems.getOrNull(it)
|
val item = (group_contacts_list.adapter as ContactsAdapter).contactItems.getOrNull(it)
|
||||||
group_contacts_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
|
group_contacts_fastscroller.updateBubbleText(item?.getBubbleText() ?: "")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(currAdapter as ContactsAdapter).updateItems(contacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +110,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems(newItems: ArrayList<Contact>) {
|
fun updateItems(newItems: ArrayList<Contact>) {
|
||||||
contactItems = newItems
|
if (newItems.hashCode() != contactItems.hashCode()) {
|
||||||
notifyDataSetChanged()
|
contactItems = newItems
|
||||||
finishActMode()
|
notifyDataSetChanged()
|
||||||
|
finishActMode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun editContact() {
|
private fun editContact() {
|
||||||
|
Reference in New Issue
Block a user