mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
fix #507, properly update week fragment at changing filtering
This commit is contained in:
@@ -220,13 +220,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateWeeklyCalendar(events: ArrayList<Event>) {
|
override fun updateWeeklyCalendar(events: ArrayList<Event>) {
|
||||||
val newHash = events.hashCode()
|
val newEvents = context!!.getFilteredEvents(events)
|
||||||
|
val newHash = newEvents.hashCode()
|
||||||
if (newHash == lastHash) {
|
if (newHash == lastHash) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
lastHash = newHash
|
lastHash = newHash
|
||||||
this.events = events
|
this.events = newEvents
|
||||||
updateEvents()
|
updateEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,8 +244,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addEvents() {
|
private fun addEvents() {
|
||||||
val filtered = context!!.getFilteredEvents(events)
|
|
||||||
|
|
||||||
initGrid()
|
initGrid()
|
||||||
allDayHolders.clear()
|
allDayHolders.clear()
|
||||||
allDayRows.clear()
|
allDayRows.clear()
|
||||||
@@ -259,7 +258,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
|
|
||||||
var hadAllDayEvent = false
|
var hadAllDayEvent = false
|
||||||
val replaceDescription = context!!.config.replaceDescription
|
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) {
|
for (event in sorted) {
|
||||||
if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
|
if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
|
||||||
hadAllDayEvent = true
|
hadAllDayEvent = true
|
||||||
|
@@ -28,7 +28,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||||||
val startTS = mTargetDate.minusDays(7).seconds()
|
val startTS = mTargetDate.minusDays(7).seconds()
|
||||||
val endTS = mTargetDate.plusDays(43).seconds()
|
val endTS = mTargetDate.plusDays(43).seconds()
|
||||||
mContext.dbHelper.getEvents(startTS, endTS) {
|
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>) {
|
private fun gotEvents(events: ArrayList<Event>) {
|
||||||
mEvents = if (mFilterEventTypes) {
|
mEvents = if (mFilterEventTypes) {
|
||||||
mContext.getFilteredEvents(events) as ArrayList<Event>
|
mContext.getFilteredEvents(events)
|
||||||
} else {
|
} else {
|
||||||
events
|
events
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ class WeeklyCalendarImpl(val mCallback: WeeklyCalendar, val mContext: Context) {
|
|||||||
val startTS = weekStartTS
|
val startTS = weekStartTS
|
||||||
val endTS = startTS + WEEK_SECONDS
|
val endTS = startTS + WEEK_SECONDS
|
||||||
mContext.dbHelper.getEvents(startTS, endTS) {
|
mContext.dbHelper.getEvents(startTS, endTS) {
|
||||||
mEvents = it as ArrayList<Event>
|
mEvents = it
|
||||||
mCallback.updateWeeklyCalendar(it)
|
mCallback.updateWeeklyCalendar(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user