show a color bar at the search results too
This commit is contained in:
parent
1c1043fb18
commit
2cb5e02179
|
@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.pro.helpers
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import androidx.collection.LongSparseArray
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
|
@ -203,6 +202,17 @@ class EventsHelper(val context: Context) {
|
|||
val events = eventsDB.getEventsForSearch(searchQuery)
|
||||
val displayEventTypes = config.displayEventTypes
|
||||
val filteredEvents = events.filter { displayEventTypes.contains(it.eventType.toString()) }
|
||||
|
||||
val eventTypeColors = LongSparseArray<Int>()
|
||||
eventTypesDB.getEventTypes().forEach {
|
||||
eventTypeColors.put(it.id!!, it.color)
|
||||
}
|
||||
|
||||
filteredEvents.forEach {
|
||||
it.updateIsPastEvent()
|
||||
it.color = eventTypeColors.get(it.eventType) ?: config.primaryColor
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
callback(text, filteredEvents)
|
||||
}
|
||||
|
@ -261,10 +271,9 @@ class EventsHelper(val context: Context) {
|
|||
eventTypeColors.put(it.id!!, it.color)
|
||||
}
|
||||
|
||||
val primaryColor = context.resources.getColor(R.color.color_primary)
|
||||
events.forEach {
|
||||
it.updateIsPastEvent()
|
||||
it.color = eventTypeColors.get(it.eventType) ?: primaryColor
|
||||
it.color = eventTypeColors.get(it.eventType) ?: config.primaryColor
|
||||
}
|
||||
|
||||
callback(events)
|
||||
|
|
Loading…
Reference in New Issue