filter out the ignored events asap
This commit is contained in:
parent
0108aa313e
commit
27436f2e91
7 changed files with 21 additions and 31 deletions
|
@ -105,7 +105,6 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
|
|||
val sublist = sorted.subList(0, Math.min(sorted.size, 100))
|
||||
var prevCode = ""
|
||||
sublist.forEach {
|
||||
if (!it.ignoreEventOccurrences.contains(it.startTS)) {
|
||||
val code = Formatter.getDayCodeFromTS(it.startTS)
|
||||
if (code != prevCode) {
|
||||
val day = Formatter.getDayTitle(context, code)
|
||||
|
@ -115,7 +114,6 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
|
|||
}
|
||||
listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay))
|
||||
}
|
||||
}
|
||||
|
||||
this@EventListWidgetAdapter.events = listItems
|
||||
}
|
||||
|
|
|
@ -162,10 +162,9 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
|
|||
override fun gotEvents(events: MutableList<Event>) {
|
||||
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })))
|
||||
val filtered = context.getFilteredEvents(sorted)
|
||||
val notIgnored = filtered.filterNot { it.ignoreEventOccurrences.contains(it.startTS) }
|
||||
|
||||
activity?.runOnUiThread {
|
||||
updateEvents(notIgnored)
|
||||
updateEvents(filtered)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
|
|||
val sublist = sorted.subList(0, Math.min(sorted.size, 100))
|
||||
var prevCode = ""
|
||||
sublist.forEach {
|
||||
if (!it.ignoreEventOccurrences.contains(it.startTS)) {
|
||||
val code = Formatter.getDayCodeFromTS(it.startTS)
|
||||
if (code != prevCode) {
|
||||
val day = Formatter.getDayTitle(context, code)
|
||||
|
@ -77,7 +76,6 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
|
|||
}
|
||||
listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay))
|
||||
}
|
||||
}
|
||||
|
||||
val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) { eventId, eventTS ->
|
||||
editEvent(eventId, eventTS)
|
||||
|
|
|
@ -232,9 +232,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
var hadAllDayEvent = false
|
||||
val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description }))
|
||||
for (event in sorted) {
|
||||
if (event.ignoreEventOccurrences.contains(event.startTS))
|
||||
continue
|
||||
|
||||
if (event.isAllDay || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
|
||||
hadAllDayEvent = true
|
||||
addAllDayEvent(event)
|
||||
|
|
|
@ -367,7 +367,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
val selectionArgs = arrayOf(toTS.toString(), fromTS.toString())
|
||||
val cursor = getEventsCursor(selection, selectionArgs)
|
||||
events.addAll(fillEvents(cursor))
|
||||
callback?.gotEvents(events)
|
||||
|
||||
val filtered = events.filterNot { it.ignoreEventOccurrences.contains(it.startTS) } as MutableList<Event>
|
||||
callback?.gotEvents(filtered)
|
||||
}
|
||||
|
||||
private fun getEventsFor(fromTS: Int, toTS: Int): List<Event> {
|
||||
|
|
|
@ -85,12 +85,9 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||
// it works more often than not, dont touch
|
||||
private fun markDaysWithEvents(days: ArrayList<Day>) {
|
||||
val eventCodes = ArrayList<String>()
|
||||
for (event in mEvents) {
|
||||
if (event.ignoreEventOccurrences.contains(event.startTS))
|
||||
continue
|
||||
|
||||
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
||||
val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
|
||||
for ((id, startTS, endTS) in mEvents) {
|
||||
val startDateTime = Formatter.getDateTimeFromTS(startTS)
|
||||
val endDateTime = Formatter.getDateTimeFromTS(endTS)
|
||||
val endCode = Formatter.getDayCodeFromDateTime(endDateTime)
|
||||
|
||||
var currDay = startDateTime
|
||||
|
|
|
@ -20,10 +20,9 @@ class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context, val
|
|||
|
||||
override fun gotEvents(events: MutableList<Event>) {
|
||||
val filtered = context.getFilteredEvents(events)
|
||||
val notIgnored = filtered.filterNot { it.ignoreEventOccurrences.contains(it.startTS) }
|
||||
val arr = SparseArray<ArrayList<Int>>(12)
|
||||
|
||||
for ((id, startTS, endTS) in notIgnored) {
|
||||
for ((id, startTS, endTS) in filtered) {
|
||||
val startDateTime = Formatter.getDateTimeFromTS(startTS)
|
||||
markDay(arr, startDateTime)
|
||||
|
||||
|
|
Loading…
Reference in a new issue