Ignore future events for status lights
This commit is contained in:
parent
a448efe09c
commit
fb9f5220d3
|
@ -74,7 +74,7 @@ class StatusLightHandler @Inject constructor(
|
|||
private fun handleAge(view: TextView?, type: TherapyEvent.Type, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
|
||||
val warn = sp.getDouble(warnSettings, defaultWarnThreshold)
|
||||
val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold)
|
||||
val therapyEvent = repository.getLastTherapyRecord(type).blockingGet()
|
||||
val therapyEvent = repository.getLastTherapyRecordUpToNow(type).blockingGet()
|
||||
if (therapyEvent is ValueWrapper.Existing) {
|
||||
warnColors.setColorByAge(view, therapyEvent.value, warn, urgent)
|
||||
view?.text = therapyEvent.value.age(resourceHelper.shortTextMode(), resourceHelper, dateUtil)
|
||||
|
|
|
@ -342,8 +342,8 @@ open class AppRepository @Inject internal constructor(
|
|||
fun deleteAllTherapyEventsEntries() =
|
||||
database.therapyEventDao.deleteAllEntries()
|
||||
|
||||
fun getLastTherapyRecord(type: TherapyEvent.Type): Single<ValueWrapper<TherapyEvent>> =
|
||||
database.therapyEventDao.getLastTherapyRecord(type).toWrappedSingle()
|
||||
fun getLastTherapyRecordUpToNow(type: TherapyEvent.Type): Single<ValueWrapper<TherapyEvent>> =
|
||||
database.therapyEventDao.getLastTherapyRecord(type, System.currentTimeMillis()).toWrappedSingle()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTherapyEventByTimestamp(type: TherapyEvent.Type, timestamp: Long): TherapyEvent? =
|
||||
|
|
|
@ -39,8 +39,8 @@ internal interface TherapyEventDao : TraceableDao<TherapyEvent> {
|
|||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTherapyEventDataIncludingInvalidFromTime(timestamp: Long): Single<List<TherapyEvent>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 ORDER BY id DESC LIMIT 1")
|
||||
fun getLastTherapyRecord(type: TherapyEvent.Type): Maybe<TherapyEvent>
|
||||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 AND timestamp <= :now ORDER BY id DESC LIMIT 1")
|
||||
fun getLastTherapyRecord(type: TherapyEvent.Type, now: Long): Maybe<TherapyEvent>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun compatGetTherapyEventDataFromTime(timestamp: Long): Single<List<TherapyEvent>>
|
||||
|
|
Loading…
Reference in a new issue