Glunovo change schedule

This commit is contained in:
Milos Kozak 2021-11-10 12:25:07 +01:00
parent 56d97861e3
commit bb7632aa80

View file

@ -25,7 +25,6 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.min
@Singleton @Singleton
class GlunovoPlugin @Inject constructor( class GlunovoPlugin @Inject constructor(
@ -64,7 +63,7 @@ class GlunovoPlugin @Inject constructor(
aapsLogger.error("Error while processing data", e) aapsLogger.error("Error while processing data", e)
} }
val lastReadTimestamp = sp.getLong(R.string.key_last_processed_glunovo_timestamp, 0L) val lastReadTimestamp = sp.getLong(R.string.key_last_processed_glunovo_timestamp, 0L)
val differenceToNow = min(INTERVAL, dateUtil.now() - lastReadTimestamp + INTERVAL + T.secs(10).msecs()) val differenceToNow = INTERVAL - (dateUtil.now() - lastReadTimestamp) % INTERVAL + T.secs(10).msecs()
loopHandler.postDelayed(refreshLoop, differenceToNow) loopHandler.postDelayed(refreshLoop, differenceToNow)
} }
} }