mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
do not show any event if every event type is filtered out
This commit is contained in:
@@ -105,7 +105,7 @@ class DayFragment : Fragment() {
|
|||||||
fun updateCalendar() {
|
fun updateCalendar() {
|
||||||
val startTS = Formatter.getDayStartTS(mDayCode)
|
val startTS = Formatter.getDayStartTS(mDayCode)
|
||||||
val endTS = Formatter.getDayEndTS(mDayCode)
|
val endTS = Formatter.getDayEndTS(mDayCode)
|
||||||
context?.dbHelper?.getEvents(startTS, endTS, applyTypeFilter = true) {
|
context?.dbHelper?.getEvents(startTS, endTS) {
|
||||||
receivedEvents(it)
|
receivedEvents(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -76,7 +76,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||||||
maxFetchedTS = DateTime().plusMonths(6).seconds()
|
maxFetchedTS = DateTime().plusMonths(6).seconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) {
|
||||||
if (it.size >= MIN_EVENTS_TRESHOLD) {
|
if (it.size >= MIN_EVENTS_TRESHOLD) {
|
||||||
receivedEvents(it, false)
|
receivedEvents(it, false)
|
||||||
} else {
|
} else {
|
||||||
@@ -84,7 +84,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||||||
minFetchedTS -= FETCH_INTERVAL
|
minFetchedTS -= FETCH_INTERVAL
|
||||||
maxFetchedTS += FETCH_INTERVAL
|
maxFetchedTS += FETCH_INTERVAL
|
||||||
}
|
}
|
||||||
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) {
|
||||||
mEvents = it
|
mEvents = it
|
||||||
receivedEvents(mEvents, false, !wereInitialEventsAdded)
|
receivedEvents(mEvents, false, !wereInitialEventsAdded)
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||||||
private fun fetchPreviousPeriod() {
|
private fun fetchPreviousPeriod() {
|
||||||
val oldMinFetchedTS = minFetchedTS - 1
|
val oldMinFetchedTS = minFetchedTS - 1
|
||||||
minFetchedTS -= FETCH_INTERVAL
|
minFetchedTS -= FETCH_INTERVAL
|
||||||
context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS, applyTypeFilter = true) {
|
context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
|
||||||
mEvents.addAll(0, it)
|
mEvents.addAll(0, it)
|
||||||
receivedEvents(mEvents, false)
|
receivedEvents(mEvents, false)
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
|
|||||||
private fun fetchNextPeriod(scrollAfterUpdating: Boolean) {
|
private fun fetchNextPeriod(scrollAfterUpdating: Boolean) {
|
||||||
val oldMaxFetchedTS = maxFetchedTS + 1
|
val oldMaxFetchedTS = maxFetchedTS + 1
|
||||||
maxFetchedTS += FETCH_INTERVAL
|
maxFetchedTS += FETCH_INTERVAL
|
||||||
context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS, applyTypeFilter = true) {
|
context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
|
||||||
mEvents.addAll(it)
|
mEvents.addAll(it)
|
||||||
receivedEvents(mEvents, scrollAfterUpdating)
|
receivedEvents(mEvents, scrollAfterUpdating)
|
||||||
}
|
}
|
||||||
|
@@ -569,7 +569,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
}.start()
|
}.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 {
|
Thread {
|
||||||
getEventsInBackground(fromTS, toTS, eventId, applyTypeFilter, callback)
|
getEventsInBackground(fromTS, toTS, eventId, applyTypeFilter, callback)
|
||||||
}.start()
|
}.start()
|
||||||
@@ -585,7 +585,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
|
|
||||||
if (applyTypeFilter) {
|
if (applyTypeFilter) {
|
||||||
val displayEventTypes = context.config.displayEventTypes
|
val displayEventTypes = context.config.displayEventTypes
|
||||||
if (displayEventTypes.isNotEmpty()) {
|
if (displayEventTypes.isEmpty()) {
|
||||||
|
callback(ArrayList())
|
||||||
|
return
|
||||||
|
} else {
|
||||||
val types = TextUtils.join(",", displayEventTypes)
|
val types = TextUtils.join(",", displayEventTypes)
|
||||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||||
}
|
}
|
||||||
@@ -616,7 +619,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
|
|
||||||
if (applyTypeFilter) {
|
if (applyTypeFilter) {
|
||||||
val displayEventTypes = context.config.displayEventTypes
|
val displayEventTypes = context.config.displayEventTypes
|
||||||
if (displayEventTypes.isNotEmpty()) {
|
if (displayEventTypes.isEmpty()) {
|
||||||
|
return ArrayList()
|
||||||
|
} else {
|
||||||
val types = TextUtils.join(",", displayEventTypes)
|
val types = TextUtils.join(",", displayEventTypes)
|
||||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||||
}
|
}
|
||||||
@@ -710,7 +715,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
|
|
||||||
if (applyTypeFilter) {
|
if (applyTypeFilter) {
|
||||||
val displayEventTypes = context.config.displayEventTypes
|
val displayEventTypes = context.config.displayEventTypes
|
||||||
if (displayEventTypes.isNotEmpty()) {
|
if (displayEventTypes.isEmpty()) {
|
||||||
|
return ArrayList()
|
||||||
|
} else {
|
||||||
val types = TextUtils.join(",", displayEventTypes)
|
val types = TextUtils.join(",", displayEventTypes)
|
||||||
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
selection += " AND $COL_EVENT_TYPE IN ($types)"
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class MonthlyCalendarImpl(val callback: MonthlyCalendar, val context: Context) {
|
|||||||
mTargetDate = targetDate
|
mTargetDate = targetDate
|
||||||
val startTS = mTargetDate.minusDays(7).seconds()
|
val startTS = mTargetDate.minusDays(7).seconds()
|
||||||
val endTS = mTargetDate.plusDays(43).seconds()
|
val endTS = mTargetDate.plusDays(43).seconds()
|
||||||
context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) {
|
context.dbHelper.getEvents(startTS, endTS) {
|
||||||
gotEvents(it)
|
gotEvents(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ class WeeklyCalendarImpl(val callback: WeeklyCalendar, val context: Context) {
|
|||||||
|
|
||||||
fun updateWeeklyCalendar(weekStartTS: Int) {
|
fun updateWeeklyCalendar(weekStartTS: Int) {
|
||||||
val endTS = weekStartTS + WEEK_SECONDS
|
val endTS = weekStartTS + WEEK_SECONDS
|
||||||
context.dbHelper.getEvents(weekStartTS, endTS, applyTypeFilter = true) {
|
context.dbHelper.getEvents(weekStartTS, endTS) {
|
||||||
mEvents = it
|
mEvents = it
|
||||||
callback.updateWeeklyCalendar(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 startDateTime = DateTime().withTime(0, 0, 0, 0).withDate(year, 1, 1)
|
||||||
val startTS = startDateTime.seconds()
|
val startTS = startDateTime.seconds()
|
||||||
val endTS = startDateTime.plusYears(1).minusSeconds(1).seconds()
|
val endTS = startDateTime.plusYears(1).minusSeconds(1).seconds()
|
||||||
context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) {
|
context.dbHelper.getEvents(startTS, endTS) {
|
||||||
gotEvents(it)
|
gotEvents(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user