Skip to content

Commit

Permalink
Modified dashboard to reload list in onResume
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Feb 3, 2024
1 parent d1bfbf2 commit 8a1f8b1
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ class DashboardFragment : Fragment(), View.OnClickListener {

@Inject
lateinit var viewModel: DashboardViewModel

private var descriptors: ArrayList<OONIDescriptor<BaseNettest>> = ArrayList()

private lateinit var binding: FragmentDashboardBinding

private lateinit var adapter: DashboardAdapter

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -58,7 +62,8 @@ class DashboardFragment : Fragment(), View.OnClickListener {
super.onViewCreated(view, savedInstanceState)
viewModel.getGroupedItemList().observe(viewLifecycleOwner) { items ->
binding.recycler.layoutManager = LinearLayoutManager(requireContext())
binding.recycler.adapter = DashboardAdapter(items, this, preferenceManager)
adapter = DashboardAdapter(items, this, preferenceManager)
binding.recycler.adapter = adapter
}

viewModel.items.observe(viewLifecycleOwner) { items ->
Expand All @@ -71,6 +76,11 @@ class DashboardFragment : Fragment(), View.OnClickListener {

override fun onResume() {
super.onResume()
/**
* Updates the list of tests when the user changes the default configuration
* after starting a test from [RunTestsActivity]
*/
binding.recycler.post { adapter.notifyDataSetChanged() }
setLastTest()
if (ReachabilityManager.isVPNinUse(this.context)
&& preferenceManager.isWarnVPNInUse
Expand Down

0 comments on commit 8a1f8b1

Please sign in to comment.