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
mFragments.put(position, fragment)
return fragment
}
fun checkDayEvents(pos: Int) {
fun updateCalendars(pos: Int) {
for (i in -1..1) {
mFragments[pos + i]?.checkEvents()
}
}
fun destroyMultiselector(pos: Int) {
for (i in -1..1) {
mFragments[pos + i]?.getDayEventsAdapter()?.finishActMode()
mFragments[pos + i]?.updateCalendar()
}
}
}

View File

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

View File

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