[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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user