diff --git a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt index 5ac00d85..fb6f3c31 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt @@ -28,6 +28,7 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis private lateinit var account: Account private lateinit var info: CollectionInfo private lateinit var journalEntity: JournalEntity + private var members: List? = null private var asyncTask: Future? = null private var emptyTextView: TextView? = null @@ -57,15 +58,10 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis val journalsManager = JournalManager(httpClient, HttpUrl.get(settings.uri!!)!!) val journal = JournalManager.Journal.fakeWithUid(journalEntity.uid) - val members = journalsManager.listMembers(journal) + members = journalsManager.listMembers(journal) uiThread { - val listAdapter = MembersListAdapter(context!!) - setListAdapter(listAdapter) - - listAdapter.addAll(members) - - emptyTextView!!.setText(R.string.collection_members_list_empty) + setListAdapterMembers(members!!) } } catch (e: Exception) { uiThread { @@ -75,6 +71,25 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis } } + private fun setListAdapterMembers(members: List) { + val context = context + if (context != null) { + val listAdapter = MembersListAdapter(context) + setListAdapter(listAdapter) + + listAdapter.addAll(members) + + emptyTextView!!.setText(R.string.collection_members_list_empty) + } + } + + override fun onResume() { + super.onResume() + if (members != null) { + setListAdapterMembers(members!!) + } + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState)