do not show any event if every event type is filtered out
This commit is contained in:
parent
717f103b59
commit
2a909e779f
6 changed files with 19 additions and 12 deletions
|
@ -105,7 +105,7 @@ class DayFragment : Fragment() {
|
|||
fun updateCalendar() {
|
||||
val startTS = Formatter.getDayStartTS(mDayCode)
|
||||
val endTS = Formatter.getDayEndTS(mDayCode)
|
||||
context?.dbHelper?.getEvents(startTS, endTS, applyTypeFilter = true) {
|
||||
context?.dbHelper?.getEvents(startTS, endTS) {
|
||||
receivedEvents(it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
maxFetchedTS = DateTime().plusMonths(6).seconds()
|
||||
}
|
||||
|
||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) {
|
||||
if (it.size >= MIN_EVENTS_TRESHOLD) {
|
||||
receivedEvents(it, false)
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
minFetchedTS -= FETCH_INTERVAL
|
||||
maxFetchedTS += FETCH_INTERVAL
|
||||
}
|
||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) {
|
||||
mEvents = it
|
||||
receivedEvents(mEvents, false, !wereInitialEventsAdded)
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
private fun fetchPreviousPeriod() {
|
||||
val oldMinFetchedTS = minFetchedTS - 1
|
||||
minFetchedTS -= FETCH_INTERVAL
|
||||
context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS, applyTypeFilter = true) {
|
||||
context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
|
||||
mEvents.addAll(0, it)
|
||||
receivedEvents(mEvents, false)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||
private fun fetchNextPeriod(scrollAfterUpdating: Boolean) {
|
||||
val oldMaxFetchedTS = maxFetchedTS + 1
|
||||
maxFetchedTS += FETCH_INTERVAL
|
||||
context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
||||
context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
|
||||
mEvents.addAll(it)
|
||||
receivedEvents(mEvents, scrollAfterUpdating)
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
}.start()
|
||||
}
|
||||
|
||||
fun getEvents(fromTS: Int, toTS: Int, eventId: Long = -1L, applyTypeFilter: Boolean = false, callback: (events: ArrayList<Event>) -> Unit) {
|
||||
fun getEvents(fromTS: Int, toTS: Int, eventId: Long = -1L, applyTypeFilter: Boolean = true, callback: (events: ArrayList<Event>) -> Unit) {
|
||||
Thread {
|
||||
getEventsInBackground(fromTS, toTS, eventId, applyTypeFilter, callback)
|
||||
}.start()
|
||||
|
@ -585,7 +585,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
|
||||
if (applyTypeFilter) {
|
||||
val displayEventTypes = context.config.displayEventTypes
|
||||
if (displayEventTypes.isNotEmpty()) {
|
||||
if (displayEventTypes.isEmpty()) {
|
||||
callback(ArrayList())
|
||||
return
|
||||
} else {
|
||||
val types = TextUtils.join(",", displayEventTypes)
|
||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||
}
|
||||
|
@ -616,7 +619,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
|
||||
if (applyTypeFilter) {
|
||||
val displayEventTypes = context.config.displayEventTypes
|
||||
if (displayEventTypes.isNotEmpty()) {
|
||||
if (displayEventTypes.isEmpty()) {
|
||||
return ArrayList()
|
||||
} else {
|
||||
val types = TextUtils.join(",", displayEventTypes)
|
||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||
}
|
||||
|
@ -710,7 +715,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
|
||||
if (applyTypeFilter) {
|
||||
val displayEventTypes = context.config.displayEventTypes
|
||||
if (displayEventTypes.isNotEmpty()) {
|
||||
if (displayEventTypes.isEmpty()) {
|
||||
return ArrayList()
|
||||
} else {
|
||||
val types = TextUtils.join(",", displayEventTypes)
|
||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class MonthlyCalendarImpl(val callback: MonthlyCalendar, val context: Context) {
|
|||
mTargetDate = targetDate
|
||||
val startTS = mTargetDate.minusDays(7).seconds()
|
||||
val endTS = mTargetDate.plusDays(43).seconds()
|
||||
context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) {
|
||||
context.dbHelper.getEvents(startTS, endTS) {
|
||||
gotEvents(it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class WeeklyCalendarImpl(val callback: WeeklyCalendar, val context: Context) {
|
|||
|
||||
fun updateWeeklyCalendar(weekStartTS: Int) {
|
||||
val endTS = weekStartTS + WEEK_SECONDS
|
||||
context.dbHelper.getEvents(weekStartTS, endTS, applyTypeFilter = true) {
|
||||
context.dbHelper.getEvents(weekStartTS, endTS) {
|
||||
mEvents = it
|
||||
callback.updateWeeklyCalendar(it)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context, val
|
|||
val startDateTime = DateTime().withTime(0, 0, 0, 0).withDate(year, 1, 1)
|
||||
val startTS = startDateTime.seconds()
|
||||
val endTS = startDateTime.plusYears(1).minusSeconds(1).seconds()
|
||||
context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) {
|
||||
context.dbHelper.getEvents(startTS, endTS) {
|
||||
gotEvents(it)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue