display the correct time. display type

This commit is contained in:
Andrei Vereha 2021-10-24 11:51:36 +02:00
parent abfd71a4b8
commit 6cd06edd29
4 changed files with 16 additions and 4 deletions

View file

@ -49,7 +49,7 @@ class DashHistory @Inject constructor(
@Suppress("ReturnCount") @Suppress("ReturnCount")
fun createRecord( fun createRecord(
commandType: OmnipodCommandType, commandType: OmnipodCommandType,
date: Long = System.currentTimeMillis(), date: Long = currentTimeMillis(),
initialResult: InitialResult = InitialResult.NOT_SENT, initialResult: InitialResult = InitialResult.NOT_SENT,
tempBasalRecord: TempBasalRecord? = null, tempBasalRecord: TempBasalRecord? = null,
bolusRecord: BolusRecord? = null, bolusRecord: BolusRecord? = null,

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data
enum class InitialResult { enum class InitialResult {
NOT_SENT, FAILURE_SENDING, UNCONFIRMED, SENT NOT_SENT, FAILURE_SENDING, SENT
} }
enum class ResolvedResult { enum class ResolvedResult {

View file

@ -20,4 +20,15 @@ data class HistoryRecordEntity(
@Embedded(prefix = "bolusRecord_") val bolusRecord: BolusRecord?, @Embedded(prefix = "bolusRecord_") val bolusRecord: BolusRecord?,
val resolvedResult: ResolvedResult?, val resolvedResult: ResolvedResult?,
val resolvedAt: Long? val resolvedAt: Long?
) ) {
fun displayTimestamp(): Long {
resolvedAt?.let {
return it
}
return date
}
fun isSuccess(): Boolean {
return initialResult == InitialResult.SENT && resolvedResult == ResolvedResult.SUCCESS
}
}

View file

@ -171,13 +171,14 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) { override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) {
val record: HistoryRecordEntity = historyList[position] val record: HistoryRecordEntity = historyList[position]
record?.let { record?.let {
holder.timeView.text = DateTimeUtil.toStringFromTimeInMillis(record.date) holder.timeView.text = DateTimeUtil.toStringFromTimeInMillis(record.displayTimestamp())
setValue(record, holder.valueView) setValue(record, holder.valueView)
setType(record, holder.typeView) setType(record, holder.typeView)
} }
} }
private fun setType(record: HistoryRecordEntity, typeView: TextView) { private fun setType(record: HistoryRecordEntity, typeView: TextView) {
typeView.text = resourceHelper.gs(record.commandType.resourceId)
} }
private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) { private fun setValue(historyEntry: HistoryRecordEntity, valueView: TextView) {