mirror of
https://github.com/etesync/android
synced 2024-11-22 07:58:09 +00:00
Members list: fix crash and handle correct lifecycle.
This commit is contained in:
parent
e3e61eb7bd
commit
41c7239a8c
@ -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<JournalManager.Member>? = null
|
||||
private var asyncTask: Future<Unit>? = 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<JournalManager.Member>) {
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user