mirror of
https://github.com/etesync/android
synced 2024-11-25 17:38:13 +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 account: Account
|
||||||
private lateinit var info: CollectionInfo
|
private lateinit var info: CollectionInfo
|
||||||
private lateinit var journalEntity: JournalEntity
|
private lateinit var journalEntity: JournalEntity
|
||||||
|
private var members: List<JournalManager.Member>? = null
|
||||||
private var asyncTask: Future<Unit>? = null
|
private var asyncTask: Future<Unit>? = null
|
||||||
|
|
||||||
private var emptyTextView: TextView? = null
|
private var emptyTextView: TextView? = null
|
||||||
@ -57,15 +58,10 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
|
|||||||
val journalsManager = JournalManager(httpClient, HttpUrl.get(settings.uri!!)!!)
|
val journalsManager = JournalManager(httpClient, HttpUrl.get(settings.uri!!)!!)
|
||||||
|
|
||||||
val journal = JournalManager.Journal.fakeWithUid(journalEntity.uid)
|
val journal = JournalManager.Journal.fakeWithUid(journalEntity.uid)
|
||||||
val members = journalsManager.listMembers(journal)
|
members = journalsManager.listMembers(journal)
|
||||||
|
|
||||||
uiThread {
|
uiThread {
|
||||||
val listAdapter = MembersListAdapter(context!!)
|
setListAdapterMembers(members!!)
|
||||||
setListAdapter(listAdapter)
|
|
||||||
|
|
||||||
listAdapter.addAll(members)
|
|
||||||
|
|
||||||
emptyTextView!!.setText(R.string.collection_members_list_empty)
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
uiThread {
|
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?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user