refresh day fragments at event update, dont recreate them

This commit is contained in:
tibbi 2018-02-10 13:16:15 +01:00
parent a5a84a400a
commit b0d4523747
3 changed files with 6 additions and 11 deletions

View File

@ -25,18 +25,13 @@ class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, p
fragment.mListener = mListener fragment.mListener = mListener
mFragments.put(position, fragment) mFragments.put(position, fragment)
return fragment return fragment
} }
fun checkDayEvents(pos: Int) { fun updateCalendars(pos: Int) {
for (i in -1..1) { for (i in -1..1) {
mFragments[pos + i]?.checkEvents() mFragments[pos + i]?.updateCalendar()
}
}
fun destroyMultiselector(pos: Int) {
for (i in -1..1) {
mFragments[pos + i]?.getDayEventsAdapter()?.finishActMode()
} }
} }
} }

View File

@ -52,7 +52,7 @@ class DayFragment : Fragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
checkEvents() updateCalendar()
} }
private fun setupButtons() { private fun setupButtons() {
@ -108,7 +108,7 @@ class DayFragment : Fragment() {
mListener?.goToDateTime(newDateTime) mListener?.goToDateTime(newDateTime)
} }
fun checkEvents() { fun updateCalendar() {
val startTS = Formatter.getDayStartTS(mDayCode) val startTS = Formatter.getDayStartTS(mDayCode)
val endTS = Formatter.getDayEndTS(mDayCode) val endTS = Formatter.getDayEndTS(mDayCode)
context!!.dbHelper.getEvents(startTS, endTS) { context!!.dbHelper.getEvents(startTS, endTS) {

View File

@ -97,7 +97,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
} }
override fun refreshEvents() { override fun refreshEvents() {
setupFragment() (viewPager?.adapter as? MyDayPagerAdapter)?.updateCalendars(viewPager?.currentItem ?: 0)
} }
override fun shouldGoToTodayBeVisible() = currentDayCode != todayDayCode override fun shouldGoToTodayBeVisible() = currentDayCode != todayDayCode