From 7f6df6c14620e8a78f4b3a29cde86cef1de52576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Hentzschel?= Date: Sat, 29 Aug 2020 16:33:55 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/14194 - avoid leak when opening the "Libraries that we use" screen --- .../mozilla/fenix/settings/about/AboutFragment.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index 8f01a1e3b4..9f80cf5e6c 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -41,7 +41,7 @@ class AboutFragment : Fragment(), AboutPageListener { private lateinit var headerAppName: String private lateinit var appName: String - private val aboutPageAdapter: AboutPageAdapter = AboutPageAdapter(this) + private var aboutPageAdapter: AboutPageAdapter? = AboutPageAdapter(this) override fun onCreateView( inflater: LayoutInflater, @@ -58,6 +58,10 @@ class AboutFragment : Fragment(), AboutPageListener { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + if (aboutPageAdapter == null) { + aboutPageAdapter = AboutPageAdapter(this) + } + about_list.run { adapter = aboutPageAdapter addItemDecoration( @@ -76,7 +80,12 @@ class AboutFragment : Fragment(), AboutPageListener { ) populateAboutHeader() - aboutPageAdapter.submitList(populateAboutList()) + aboutPageAdapter?.submitList(populateAboutList()) + } + + override fun onDestroyView() { + super.onDestroyView() + aboutPageAdapter = null } private fun populateAboutHeader() {