mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
sort groups by title alphabetically
This commit is contained in:
parent
796cb13c9c
commit
25b8babc17
@ -12,10 +12,13 @@ import com.simplemobiletools.contacts.extensions.config
|
|||||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.contacts.interfaces.FragmentInterface
|
import com.simplemobiletools.contacts.interfaces.FragmentInterface
|
||||||
import com.simplemobiletools.contacts.models.Contact
|
import com.simplemobiletools.contacts.models.Contact
|
||||||
|
import com.simplemobiletools.contacts.models.Group
|
||||||
import kotlinx.android.synthetic.main.fragment_groups.view.*
|
import kotlinx.android.synthetic.main.fragment_groups.view.*
|
||||||
|
|
||||||
class GroupsFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet), FragmentInterface {
|
class GroupsFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet), FragmentInterface {
|
||||||
var activity: MainActivity? = null
|
var activity: MainActivity? = null
|
||||||
|
var lastContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
override fun setupFragment(activity: MainActivity) {
|
override fun setupFragment(activity: MainActivity) {
|
||||||
if (this.activity == null) {
|
if (this.activity == null) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
@ -41,7 +44,8 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : Coordinator
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val storedGroups = ContactsHelper(activity!!).getStoredGroups()
|
lastContacts = contacts
|
||||||
|
var storedGroups = ContactsHelper(activity!!).getStoredGroups()
|
||||||
contacts.forEach {
|
contacts.forEach {
|
||||||
it.groups.forEach {
|
it.groups.forEach {
|
||||||
val group = it
|
val group = it
|
||||||
@ -50,6 +54,7 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : Coordinator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storedGroups = storedGroups.sortedWith(compareBy { it.title }).toList() as ArrayList<Group>
|
||||||
val currAdapter = groups_list.adapter
|
val currAdapter = groups_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
GroupsAdapter(activity as SimpleActivity, storedGroups, groups_list, groups_fastscroller) {
|
GroupsAdapter(activity as SimpleActivity, storedGroups, groups_list, groups_fastscroller) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user