filter out the ignored events asap

This commit is contained in:
tibbi 2017-03-05 21:00:50 +01:00
parent 0108aa313e
commit 27436f2e91
7 changed files with 21 additions and 31 deletions

View file

@ -105,7 +105,6 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
val sublist = sorted.subList(0, Math.min(sorted.size, 100)) val sublist = sorted.subList(0, Math.min(sorted.size, 100))
var prevCode = "" var prevCode = ""
sublist.forEach { sublist.forEach {
if (!it.ignoreEventOccurrences.contains(it.startTS)) {
val code = Formatter.getDayCodeFromTS(it.startTS) val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode) { if (code != prevCode) {
val day = Formatter.getDayTitle(context, code) 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)) listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay))
} }
}
this@EventListWidgetAdapter.events = listItems this@EventListWidgetAdapter.events = listItems
} }

View file

@ -162,10 +162,9 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DBHelper.GetEvents
override fun gotEvents(events: MutableList<Event>) { override fun gotEvents(events: MutableList<Event>) {
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description }))) val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })))
val filtered = context.getFilteredEvents(sorted) val filtered = context.getFilteredEvents(sorted)
val notIgnored = filtered.filterNot { it.ignoreEventOccurrences.contains(it.startTS) }
activity?.runOnUiThread { activity?.runOnUiThread {
updateEvents(notIgnored) updateEvents(filtered)
} }
} }
} }

View file

@ -68,7 +68,6 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event
val sublist = sorted.subList(0, Math.min(sorted.size, 100)) val sublist = sorted.subList(0, Math.min(sorted.size, 100))
var prevCode = "" var prevCode = ""
sublist.forEach { sublist.forEach {
if (!it.ignoreEventOccurrences.contains(it.startTS)) {
val code = Formatter.getDayCodeFromTS(it.startTS) val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode) { if (code != prevCode) {
val day = Formatter.getDayTitle(context, code) 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)) 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 -> val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) { eventId, eventTS ->
editEvent(eventId, eventTS) editEvent(eventId, eventTS)

View file

@ -232,9 +232,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var hadAllDayEvent = false var hadAllDayEvent = false
val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })) val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description }))
for (event in sorted) { for (event in sorted) {
if (event.ignoreEventOccurrences.contains(event.startTS))
continue
if (event.isAllDay || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) { if (event.isAllDay || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
hadAllDayEvent = true hadAllDayEvent = true
addAllDayEvent(event) addAllDayEvent(event)

View file

@ -367,7 +367,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
val selectionArgs = arrayOf(toTS.toString(), fromTS.toString()) val selectionArgs = arrayOf(toTS.toString(), fromTS.toString())
val cursor = getEventsCursor(selection, selectionArgs) val cursor = getEventsCursor(selection, selectionArgs)
events.addAll(fillEvents(cursor)) 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> { private fun getEventsFor(fromTS: Int, toTS: Int): List<Event> {

View file

@ -85,12 +85,9 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
// it works more often than not, dont touch // it works more often than not, dont touch
private fun markDaysWithEvents(days: ArrayList<Day>) { private fun markDaysWithEvents(days: ArrayList<Day>) {
val eventCodes = ArrayList<String>() val eventCodes = ArrayList<String>()
for (event in mEvents) { for ((id, startTS, endTS) in mEvents) {
if (event.ignoreEventOccurrences.contains(event.startTS)) val startDateTime = Formatter.getDateTimeFromTS(startTS)
continue val endDateTime = Formatter.getDateTimeFromTS(endTS)
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
val endCode = Formatter.getDayCodeFromDateTime(endDateTime) val endCode = Formatter.getDayCodeFromDateTime(endDateTime)
var currDay = startDateTime var currDay = startDateTime

View file

@ -20,10 +20,9 @@ class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context, val
override fun gotEvents(events: MutableList<Event>) { override fun gotEvents(events: MutableList<Event>) {
val filtered = context.getFilteredEvents(events) val filtered = context.getFilteredEvents(events)
val notIgnored = filtered.filterNot { it.ignoreEventOccurrences.contains(it.startTS) }
val arr = SparseArray<ArrayList<Int>>(12) val arr = SparseArray<ArrayList<Int>>(12)
for ((id, startTS, endTS) in notIgnored) { for ((id, startTS, endTS) in filtered) {
val startDateTime = Formatter.getDateTimeFromTS(startTS) val startDateTime = Formatter.getDateTimeFromTS(startTS)
markDay(arr, startDateTime) markDay(arr, startDateTime)