[LeakCanary] Fragment: Explicity set viewpager2 adapter to null

* Also use viewLifecycleOwner to get lifecycle

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-03-20 13:50:14 +05:30
parent 3a27fa719b
commit 0b07c3cecb
4 changed files with 9 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ class AppsContainerFragment : Fragment(R.layout.fragment_apps_games) {
binding.pager.adapter = ViewPagerAdapter(
childFragmentManager,
lifecycle,
viewLifecycleOwner.lifecycle,
isGoogleAccount,
isForYouEnabled
)
@@ -94,6 +94,7 @@ class AppsContainerFragment : Fragment(R.layout.fragment_apps_games) {
override fun onDestroyView() {
super.onDestroyView()
binding.pager.adapter = null
_binding = null
}

View File

@@ -59,7 +59,8 @@ class TopChartContainerFragment : Fragment(R.layout.fragment_top_chart) {
}
// ViewPager
binding.pager.adapter = ViewPagerAdapter(childFragmentManager, lifecycle, chartType)
binding.pager.adapter =
ViewPagerAdapter(childFragmentManager, viewLifecycleOwner.lifecycle, chartType)
binding.topTabGroup.setOnCheckedStateChangeListener { _, checkedIds ->
when (checkedIds[0]) {
R.id.tab_top_free -> binding.pager.setCurrentItem(0, true)
@@ -84,6 +85,7 @@ class TopChartContainerFragment : Fragment(R.layout.fragment_top_chart) {
override fun onDestroyView() {
super.onDestroyView()
binding.pager.adapter = null
_binding = null
}

View File

@@ -58,7 +58,7 @@ class GamesContainerFragment : Fragment(R.layout.fragment_apps_games) {
binding.pager.adapter = ViewPagerAdapter(
childFragmentManager,
lifecycle,
viewLifecycleOwner.lifecycle,
isGoogleAccount,
isForYouEnabled
)
@@ -93,6 +93,7 @@ class GamesContainerFragment : Fragment(R.layout.fragment_apps_games) {
override fun onDestroyView() {
super.onDestroyView()
binding.pager.adapter = null
_binding = null
}

View File

@@ -90,7 +90,7 @@ class SpoofFragment : Fragment(R.layout.activity_generic_pager) {
}
// ViewPager
binding.pager.adapter = ViewPagerAdapter(childFragmentManager, lifecycle)
binding.pager.adapter = ViewPagerAdapter(childFragmentManager, viewLifecycleOwner.lifecycle)
TabLayoutMediator(
binding.tabLayout,
@@ -108,6 +108,7 @@ class SpoofFragment : Fragment(R.layout.activity_generic_pager) {
override fun onDestroyView() {
super.onDestroyView()
binding.pager.adapter = null
_binding = null
}