mirror of
https://github.com/etesync/android
synced 2024-12-24 23:48:35 +00:00
Fix potential crash when there's an error getting journal members.
This commit is contained in:
parent
ea81696424
commit
15309911a5
@ -35,9 +35,9 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
data = (context!!.applicationContext as App).data
|
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
|
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? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
@ -51,28 +51,27 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
|
|||||||
|
|
||||||
override fun refresh() {
|
override fun refresh() {
|
||||||
asyncTask = doAsync {
|
asyncTask = doAsync {
|
||||||
var members: List<JournalManager.Member>? = null;
|
|
||||||
try {
|
try {
|
||||||
val settings = AccountSettings(context!!, account!!)
|
val settings = AccountSettings(context!!, account)
|
||||||
val httpClient = HttpClient.create(context!!, settings)
|
val httpClient = HttpClient.create(context!!, settings)
|
||||||
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)
|
||||||
members = journalsManager.listMembers(journal)
|
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) {
|
} catch (e: Exception) {
|
||||||
uiThread {
|
uiThread {
|
||||||
emptyTextView!!.text = e.localizedMessage
|
emptyTextView!!.text = e.localizedMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uiThread {
|
|
||||||
val listAdapter = MembersListAdapter(context!!)
|
|
||||||
setListAdapter(listAdapter)
|
|
||||||
|
|
||||||
listAdapter.addAll(members)
|
|
||||||
|
|
||||||
emptyTextView!!.setText(R.string.collection_members_list_empty)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user