fix #507, properly update week fragment at changing filtering

This commit is contained in:
tibbi 2018-05-26 19:32:07 +02:00
parent 1489b70f41
commit 37569ca309
3 changed files with 7 additions and 8 deletions

View File

@ -220,13 +220,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
override fun updateWeeklyCalendar(events: ArrayList<Event>) {
val newHash = events.hashCode()
val newEvents = context!!.getFilteredEvents(events)
val newHash = newEvents.hashCode()
if (newHash == lastHash) {
return
}
lastHash = newHash
this.events = events
this.events = newEvents
updateEvents()
}
@ -243,8 +244,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun addEvents() {
val filtered = context!!.getFilteredEvents(events)
initGrid()
allDayHolders.clear()
allDayRows.clear()
@ -259,7 +258,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var hadAllDayEvent = false
val replaceDescription = context!!.config.replaceDescription
val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
val sorted = events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
for (event in sorted) {
if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
hadAllDayEvent = true

View File

@ -28,7 +28,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
val startTS = mTargetDate.minusDays(7).seconds()
val endTS = mTargetDate.plusDays(43).seconds()
mContext.dbHelper.getEvents(startTS, endTS) {
gotEvents(it as ArrayList<Event>)
gotEvents(it)
}
}
@ -131,7 +131,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
private fun gotEvents(events: ArrayList<Event>) {
mEvents = if (mFilterEventTypes) {
mContext.getFilteredEvents(events) as ArrayList<Event>
mContext.getFilteredEvents(events)
} else {
events
}

View File

@ -14,7 +14,7 @@ class WeeklyCalendarImpl(val mCallback: WeeklyCalendar, val mContext: Context) {
val startTS = weekStartTS
val endTS = startTS + WEEK_SECONDS
mContext.dbHelper.getEvents(startTS, endTS) {
mEvents = it as ArrayList<Event>
mEvents = it
mCallback.updateWeeklyCalendar(it)
}
}