diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 0d86c4cd24..aaef1ddf01 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -51,6 +51,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor( private val carouselStateFactory: SplashCarouselStateFactory ) : AbstractFtueAuthFragment() { + private var tabLayoutMediator: TabLayoutMediator? = null + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueSplashCarouselBinding { return FragmentFtueSplashCarouselBinding.inflate(inflater, container, false) } @@ -60,10 +62,19 @@ class FtueAuthSplashCarouselFragment @Inject constructor( setupViews() } + override fun onDestroyView() { + tabLayoutMediator?.detach() + tabLayoutMediator = null + views.splashCarousel.adapter = null + super.onDestroyView() + } + private fun setupViews() { val carouselAdapter = carouselController.adapter views.splashCarousel.adapter = carouselAdapter - TabLayoutMediator(views.carouselIndicator, views.splashCarousel) { _, _ -> }.attach() + tabLayoutMediator = TabLayoutMediator(views.carouselIndicator, views.splashCarousel) { _, _ -> } + .also { it.attach() } + carouselController.setData(carouselStateFactory.create()) val isAlreadyHaveAccountEnabled = vectorFeatures.isOnboardingAlreadyHaveAccountSplashEnabled()