fix #507, properly update week fragment at changing filtering
This commit is contained in:
parent
1489b70f41
commit
37569ca309
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue