mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 17:38:26 +00:00
Update ContactSelectionListFragment.kt
Manual loader destruction and logging for the loader callback activity check.
This commit is contained in:
parent
72999c7d12
commit
59b94a1744
@ -55,6 +55,11 @@ class ContactSelectionListFragment : Fragment(), LoaderManager.LoaderCallbacks<L
|
|||||||
super.onStart()
|
super.onStart()
|
||||||
LoaderManager.getInstance(this).initLoader(0, null, this)
|
LoaderManager.getInstance(this).initLoader(0, null, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
LoaderManager.getInstance(this).destroyLoader(0)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.contact_selection_list_fragment, container, false)
|
return inflater.inflate(R.layout.contact_selection_list_fragment, container, false)
|
||||||
@ -92,8 +97,13 @@ class ContactSelectionListFragment : Fragment(), LoaderManager.LoaderCallbacks<L
|
|||||||
update(listOf())
|
update(listOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun update(items: List<ContactSelectionListItem>) {
|
private fun update(items: List<ContactSelectionListItem>) {
|
||||||
if (activity?.isDestroyed == true) { return }
|
if (activity?.isDestroyed == true) {
|
||||||
|
Log.e(ContactSelectionListFragment::class.java.name,
|
||||||
|
"Received a loader callback after the fragment was detached from an activity.",
|
||||||
|
IllegalStateException())
|
||||||
|
return
|
||||||
|
}
|
||||||
listAdapter.items = items
|
listAdapter.items = items
|
||||||
mainContentContainer.visibility = if (items.isEmpty()) View.GONE else View.VISIBLE
|
mainContentContainer.visibility = if (items.isEmpty()) View.GONE else View.VISIBLE
|
||||||
emptyStateContainer.visibility = if (items.isEmpty()) View.VISIBLE else View.GONE
|
emptyStateContainer.visibility = if (items.isEmpty()) View.VISIBLE else View.GONE
|
||||||
@ -110,4 +120,4 @@ class ContactSelectionListFragment : Fragment(), LoaderManager.LoaderCallbacks<L
|
|||||||
override fun onContactDeselected(contact: Recipient) {
|
override fun onContactDeselected(contact: Recipient) {
|
||||||
onContactSelectedListener?.onContactDeselected(contact.address.serialize())
|
onContactSelectedListener?.onContactDeselected(contact.address.serialize())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user