refresh day fragments at event update, dont recreate them
This commit is contained in:
parent
a5a84a400a
commit
b0d4523747
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue