forked from shihaam/thijooree
Bug fix: contacts page infinite loading without internet
This commit is contained in:
@@ -48,7 +48,6 @@ class ContactsFragment : Fragment() {
|
|||||||
private var currentSearch: String = ""
|
private var currentSearch: String = ""
|
||||||
private var mediator: TabLayoutMediator? = null
|
private var mediator: TabLayoutMediator? = null
|
||||||
private lateinit var pagerAdapter: ContactsPagerAdapter
|
private lateinit var pagerAdapter: ContactsPagerAdapter
|
||||||
private var contactsRefreshing = false
|
|
||||||
|
|
||||||
private data class TabPage(val categoryId: String?, val label: String)
|
private data class TabPage(val categoryId: String?, val label: String)
|
||||||
|
|
||||||
@@ -136,8 +135,8 @@ class ContactsFragment : Fragment() {
|
|||||||
(activity as? HomeActivity)?.loadAllContacts()
|
(activity as? HomeActivity)?.loadAllContacts()
|
||||||
|
|
||||||
binding.swipeRefresh.setOnRefreshListener {
|
binding.swipeRefresh.setOnRefreshListener {
|
||||||
contactsRefreshing = true
|
|
||||||
(activity as? HomeActivity)?.triggerRefresh()
|
(activity as? HomeActivity)?.triggerRefresh()
|
||||||
|
binding.swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.contactCategories.observe(viewLifecycleOwner) { cats ->
|
viewModel.contactCategories.observe(viewLifecycleOwner) { cats ->
|
||||||
@@ -149,10 +148,6 @@ class ContactsFragment : Fragment() {
|
|||||||
pagerAdapter.updateContacts(allContacts)
|
pagerAdapter.updateContacts(allContacts)
|
||||||
binding.emptyView.visibility = if (contacts.isEmpty()) View.VISIBLE else View.GONE
|
binding.emptyView.visibility = if (contacts.isEmpty()) View.VISIBLE else View.GONE
|
||||||
binding.loadingView.visibility = View.GONE
|
binding.loadingView.visibility = View.GONE
|
||||||
if (contactsRefreshing) {
|
|
||||||
contactsRefreshing = false
|
|
||||||
binding.swipeRefresh.isRefreshing = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class FinancingFragment : Fragment() {
|
|||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
private val viewModel: HomeViewModel by activityViewModels()
|
private val viewModel: HomeViewModel by activityViewModels()
|
||||||
private lateinit var adapter: FinancingAdapter
|
private lateinit var adapter: FinancingAdapter
|
||||||
private var financingRefreshing = false
|
|
||||||
|
|
||||||
private var latestMibDeals: List<MibFinanceDeal> = emptyList()
|
private var latestMibDeals: List<MibFinanceDeal> = emptyList()
|
||||||
private var latestBmlLoanDetails: Map<String, BmlLoanDetail> = emptyMap()
|
private var latestBmlLoanDetails: Map<String, BmlLoanDetail> = emptyMap()
|
||||||
@@ -46,8 +45,8 @@ class FinancingFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.swipeRefresh.setOnRefreshListener {
|
binding.swipeRefresh.setOnRefreshListener {
|
||||||
financingRefreshing = true
|
|
||||||
(activity as? HomeActivity)?.triggerRefresh()
|
(activity as? HomeActivity)?.triggerRefresh()
|
||||||
|
binding.swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.accounts.observe(viewLifecycleOwner) { rebuildAdapter() }
|
viewModel.accounts.observe(viewLifecycleOwner) { rebuildAdapter() }
|
||||||
@@ -74,10 +73,6 @@ class FinancingFragment : Fragment() {
|
|||||||
binding.recyclerView.visibility = if (isEmpty) View.GONE else View.VISIBLE
|
binding.recyclerView.visibility = if (isEmpty) View.GONE else View.VISIBLE
|
||||||
binding.emptyView.visibility = if (isEmpty) View.VISIBLE else View.GONE
|
binding.emptyView.visibility = if (isEmpty) View.VISIBLE else View.GONE
|
||||||
binding.loadingView.visibility = View.GONE
|
binding.loadingView.visibility = View.GONE
|
||||||
if (financingRefreshing) {
|
|
||||||
financingRefreshing = false
|
|
||||||
binding.swipeRefresh.isRefreshing = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|||||||
Reference in New Issue
Block a user