From dd6e3dd111fda5b9727c57276b9533e0156bf7e3 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Thu, 4 Mar 2021 19:10:37 -0800 Subject: [PATCH] Fix add-on search --- .../mozilla/fenix/addons/AddonsManagementFragment.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt b/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt index 426501046cca..a98a767a96e5 100644 --- a/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt @@ -65,6 +65,8 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) */ private var isInstallationInProgress = false private var adapter: PagedAddonsManagerAdapter? = null + // We must save the add-on list in the class, or we won't have it + // downloaded for the non-suspending search function private var addons: List? = null override fun onCreateView( @@ -176,14 +178,14 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) val allowCache = args.installAddonId == null || installExternalAddonComplete lifecycleScope.launch(IO) { try { - val addons = requireContext().components.addonManager.getAddons(allowCache = allowCache) + addons = requireContext().components.addonManager.getAddons(allowCache = allowCache) lifecycleScope.launch(Dispatchers.Main) { runIfFragmentIsAttached { if (!shouldRefresh) { adapter = PagedAddonsManagerAdapter( requireContext().components.addonCollectionProvider, managementView, - addons, + addons!!, style = createAddonStyle(requireContext()) ) } @@ -193,12 +195,12 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) recyclerView.adapter = adapter if (shouldRefresh) { - adapter?.updateAddons(addons) + adapter?.updateAddons(addons!!) } args.installAddonId?.let { addonIn -> if (!installExternalAddonComplete) { - installExternalAddon(addons, addonIn) + installExternalAddon(addons!!, addonIn) } } }