From 25b8babc17e641007ef438b76b9a1100bef9e788 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 19 Mar 2018 17:18:17 +0100 Subject: [PATCH] sort groups by title alphabetically --- .../simplemobiletools/contacts/fragments/GroupsFragment.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/GroupsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/GroupsFragment.kt index ea2f2731..fca777b7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/GroupsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/GroupsFragment.kt @@ -12,10 +12,13 @@ import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.helpers.ContactsHelper import com.simplemobiletools.contacts.interfaces.FragmentInterface import com.simplemobiletools.contacts.models.Contact +import com.simplemobiletools.contacts.models.Group import kotlinx.android.synthetic.main.fragment_groups.view.* class GroupsFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet), FragmentInterface { var activity: MainActivity? = null + var lastContacts = ArrayList() + override fun setupFragment(activity: MainActivity) { if (this.activity == null) { this.activity = activity @@ -41,7 +44,8 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : Coordinator return } - val storedGroups = ContactsHelper(activity!!).getStoredGroups() + lastContacts = contacts + var storedGroups = ContactsHelper(activity!!).getStoredGroups() contacts.forEach { it.groups.forEach { val group = it @@ -50,6 +54,7 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : Coordinator } } + storedGroups = storedGroups.sortedWith(compareBy { it.title }).toList() as ArrayList val currAdapter = groups_list.adapter if (currAdapter == null) { GroupsAdapter(activity as SimpleActivity, storedGroups, groups_list, groups_fastscroller) {