diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/ViewPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/ViewPagerAdapter.kt index 8094f236..9a452e35 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/adapters/ViewPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/adapters/ViewPagerAdapter.kt @@ -15,8 +15,14 @@ class ViewPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) { private val fragments = HashMap() override fun getItem(position: Int): Fragment { - val fragment = getFragment(position) - fragments[position] = fragment + return getFragment(position) + } + + override fun instantiateItem(container: ViewGroup, position: Int): Any { + val fragment = super.instantiateItem(container, position) + if (fragment is Fragment) { + fragments[position] = fragment + } return fragment }