0
0
mirror of https://github.com/etesync/android.git synced 2024-09-20 21:13:05 +02:00

Fix potential crash when there's an error getting journal members.

This commit is contained in:
Tom Hacohen 2019-01-09 20:44:04 +00:00
parent ea81696424
commit 15309911a5

View File

@ -35,9 +35,9 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
data = (context!!.applicationContext as App).data
account = arguments!!.getParcelable(Constants.KEY_ACCOUNT)
account = arguments!!.getParcelable(Constants.KEY_ACCOUNT)!!
info = arguments!!.getSerializable(Constants.KEY_COLLECTION_INFO) as CollectionInfo
journalEntity = JournalModel.Journal.fetch(data!!, info!!.getServiceEntity(data), info!!.uid)
journalEntity = JournalModel.Journal.fetch(data, info.getServiceEntity(data), info.uid)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -51,28 +51,27 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
override fun refresh() {
asyncTask = doAsync {
var members: List<JournalManager.Member>? = null;
try {
val settings = AccountSettings(context!!, account!!)
val settings = AccountSettings(context!!, account)
val httpClient = HttpClient.create(context!!, settings)
val journalsManager = JournalManager(httpClient, HttpUrl.get(settings.uri!!)!!)
val journal = JournalManager.Journal.fakeWithUid(journalEntity!!.uid)
members = journalsManager.listMembers(journal)
val journal = JournalManager.Journal.fakeWithUid(journalEntity.uid)
val members = journalsManager.listMembers(journal)
uiThread {
val listAdapter = MembersListAdapter(context!!)
setListAdapter(listAdapter)
listAdapter.addAll(members)
emptyTextView!!.setText(R.string.collection_members_list_empty)
}
} catch (e: Exception) {
uiThread {
emptyTextView!!.text = e.localizedMessage
}
}
uiThread {
val listAdapter = MembersListAdapter(context!!)
setListAdapter(listAdapter)
listAdapter.addAll(members)
emptyTextView!!.setText(R.string.collection_members_list_empty)
}
}
}