diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt index 93f375aab..a6df6c179 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt @@ -11,7 +11,7 @@ import com.simplemobiletools.calendar.interfaces.NavigationListener class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) { - var fragments: SparseArray = SparseArray(10) + private val mFragments = SparseArray() override fun getCount() = mCodes.size @@ -20,18 +20,16 @@ class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List, p val code = mCodes[position] bundle.putString(DAY_CODE, code) - if (fragments.get(position) != null) - return fragments[position] - val fragment = DayFragment() fragment.arguments = bundle fragment.setListener(mListener) - fragments.put(position, fragment) + + mFragments.put(position, fragment) return fragment } fun checkDayEvents(pos: Int) { - fragments.get(pos - 1)?.checkEvents() - fragments.get(pos + 1)?.checkEvents() + mFragments[pos - 1].checkEvents() + mFragments[pos + 1].checkEvents() } }