kotlin lints
This commit is contained in:
parent
c77fbcd473
commit
f2e86ae63c
|
@ -13,7 +13,7 @@ class TokenizationTest {
|
|||
// Trying to match it at those coordinates is expected to succeed,
|
||||
// while trying to match it slightly to the right should fail.
|
||||
|
||||
val largeBasalGlyphPattern = glyphPatterns[Glyph.LargeSymbol(LargeSymbol.BASAL)]!!
|
||||
val largeBasalGlyphPattern = glyphPatterns.getValue(Glyph.LargeSymbol(LargeSymbol.BASAL))
|
||||
|
||||
val result1 = checkIfPatternMatchesAt(
|
||||
testFrameMainScreenWithTimeSeparator,
|
||||
|
|
|
@ -614,21 +614,21 @@ class BigLogInquireResponsePacket(
|
|||
var recordMap: MutableMap<String, Double> = mutableMapOf("dummy" to 0.0)
|
||||
|
||||
if (dailyMaxValInfo.containsKey(recordDateStr)) {
|
||||
recordMap = dailyMaxValInfo[recordDateStr]!!
|
||||
recordMap = dailyMaxValInfo.getValue(recordDateStr)
|
||||
} else {
|
||||
recordMap["bolus"] = 0.0
|
||||
recordMap["basal"] = 0.0
|
||||
dailyMaxValInfo[recordDateStr] = recordMap
|
||||
}
|
||||
|
||||
if (diaconnG8HistoryRecord.dailyBolus > recordMap["bolus"]!!) {
|
||||
if (diaconnG8HistoryRecord.dailyBolus > recordMap.getValue("bolus")) {
|
||||
recordMap["bolus"] = diaconnG8HistoryRecord.dailyBolus
|
||||
} else {
|
||||
diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
|
||||
diaconnG8HistoryRecord.dailyBolus = recordMap.getValue("bolus")
|
||||
}
|
||||
|
||||
if (recordMap["basal"]!! > 0.0) {
|
||||
diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
|
||||
if (recordMap.getValue("basal") > 0.0) {
|
||||
diaconnG8HistoryRecord.dailyBasal = recordMap.getValue("basal")
|
||||
}
|
||||
diaconnG8HistoryRecord.lognum = logNum
|
||||
diaconnG8HistoryRecord.wrappingCount = wrappingCount
|
||||
|
@ -663,21 +663,21 @@ class BigLogInquireResponsePacket(
|
|||
var recordMap: MutableMap<String, Double> = mutableMapOf("dummy" to 0.0)
|
||||
|
||||
if (dailyMaxValInfo.containsKey(recordDateStr)) {
|
||||
recordMap = dailyMaxValInfo[recordDateStr]!!
|
||||
recordMap = dailyMaxValInfo.getValue(recordDateStr)
|
||||
} else {
|
||||
recordMap["bolus"] = 0.0
|
||||
recordMap["basal"] = 0.0
|
||||
dailyMaxValInfo[recordDateStr] = recordMap
|
||||
}
|
||||
|
||||
if (diaconnG8HistoryRecord.dailyBasal > recordMap["basal"]!!) {
|
||||
if (diaconnG8HistoryRecord.dailyBasal > recordMap.getValue("basal")) {
|
||||
recordMap["basal"] = diaconnG8HistoryRecord.dailyBasal
|
||||
} else {
|
||||
diaconnG8HistoryRecord.dailyBasal = recordMap["basal"]!!
|
||||
diaconnG8HistoryRecord.dailyBasal = recordMap.getValue("basal")
|
||||
}
|
||||
|
||||
if (recordMap["bolus"]!! > 0.0) {
|
||||
diaconnG8HistoryRecord.dailyBolus = recordMap["bolus"]!!
|
||||
if (recordMap.getValue("bolus") > 0.0) {
|
||||
diaconnG8HistoryRecord.dailyBolus = recordMap.getValue("bolus")
|
||||
}
|
||||
diaconnG8HistoryRecord.lognum = logNum
|
||||
diaconnG8HistoryRecord.wrappingCount = wrappingCount
|
||||
|
|
|
@ -25,13 +25,13 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
var id: Long = 0
|
||||
|
||||
@Expose
|
||||
var DT: String? = null
|
||||
var dt: String? = null
|
||||
|
||||
@Expose
|
||||
var atechDateTime: Long = 0L
|
||||
set(value) {
|
||||
field = value
|
||||
DT = DateTimeUtil.toString(value)
|
||||
dt = DateTimeUtil.toString(value)
|
||||
if (isEntryTypeSet() && value != 0L) pumpId = generatePumpId()
|
||||
}
|
||||
|
||||
|
@ -49,22 +49,6 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
return field
|
||||
}
|
||||
|
||||
/**
|
||||
* if history object is already linked to AAPS object (either Treatment, TempBasal or TDD (tdd's
|
||||
* are not actually
|
||||
* linked))
|
||||
*/
|
||||
var linked = false
|
||||
|
||||
/**
|
||||
* Linked object, see linked
|
||||
*/
|
||||
var linkedObject: Any? = null
|
||||
set(value) {
|
||||
linked = true
|
||||
field = value
|
||||
}
|
||||
|
||||
abstract fun generatePumpId(): Long
|
||||
|
||||
abstract fun isEntryTypeSet(): Boolean
|
||||
|
@ -107,16 +91,16 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
}
|
||||
|
||||
val dateTimeString: String
|
||||
get() = if (DT == null) "Unknown" else DT!!
|
||||
get() = dt ?: "Unknown"
|
||||
|
||||
val decodedDataAsString: String
|
||||
get() = if (decodedData.size == 0) if (isNoDataEntry) "No data" else "" else decodedData.toString()
|
||||
get() = if (decodedData.isEmpty()) if (isNoDataEntry) "No data" else "" else decodedData.toString()
|
||||
|
||||
fun hasData(): Boolean {
|
||||
return decodedData.size == 0 || isNoDataEntry || entryTypeName == "UnabsorbedInsulin"
|
||||
private fun hasData(): Boolean {
|
||||
return decodedData.isEmpty() || isNoDataEntry || entryTypeName == "UnabsorbedInsulin"
|
||||
}
|
||||
|
||||
val isNoDataEntry: Boolean
|
||||
private val isNoDataEntry: Boolean
|
||||
get() = sizes[0] == 2 && sizes[1] == 5 && sizes[2] == 0
|
||||
|
||||
fun getDecodedDataEntry(key: String?): Any? {
|
||||
|
@ -127,17 +111,16 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
return decodedData.containsKey(key)
|
||||
}
|
||||
|
||||
fun showRaw(): Boolean {
|
||||
return entryTypeName == "EndResultTotals"
|
||||
}
|
||||
private fun showRaw(): Boolean =
|
||||
entryTypeName == "EndResultTotals"
|
||||
|
||||
val headLength: Int
|
||||
private val headLength: Int
|
||||
get() = sizes[0]
|
||||
|
||||
val dateTimeLength: Int
|
||||
get() = sizes[1]
|
||||
|
||||
val bodyLength: Int
|
||||
private val bodyLength: Int
|
||||
get() = sizes[2]
|
||||
|
||||
abstract fun toEntryString(): String
|
||||
|
@ -148,7 +131,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
// Log.e("", "DT is null. RawData=" + ByteUtil.getHex(rawData))
|
||||
// }
|
||||
sb.append(toStringStart)
|
||||
sb.append(", DT: " + if (DT == null) "null" else StringUtil.getStringInLength(DT, 19))
|
||||
sb.append(", DT: " + if (dt == null) "null" else StringUtil.getStringInLength(dt, 19))
|
||||
sb.append(", length=")
|
||||
sb.append(headLength)
|
||||
sb.append(",")
|
||||
|
@ -171,11 +154,11 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
sb.append(", head=")
|
||||
sb.append(ByteUtil.shortHexString(head))
|
||||
}
|
||||
if (datetime.size != 0) {
|
||||
if (datetime.isNotEmpty()) {
|
||||
sb.append(", datetime=")
|
||||
sb.append(ByteUtil.shortHexString(datetime))
|
||||
}
|
||||
if (body.size != 0) {
|
||||
if (body.isNotEmpty()) {
|
||||
sb.append(", body=")
|
||||
sb.append(ByteUtil.shortHexString(body))
|
||||
}
|
||||
|
@ -206,15 +189,7 @@ abstract class MedtronicHistoryEntry : MedtronicHistoryEntryInterface {
|
|||
}
|
||||
|
||||
fun addDecodedData(key: String, value: Any) {
|
||||
decodedData.put(key, value)
|
||||
}
|
||||
|
||||
fun toShortString(): String {
|
||||
return if (head.size != 0) {
|
||||
"Unidentified record. "
|
||||
} else {
|
||||
"HistoryRecord: head=[" + ByteUtil.shortHexString(head) + "]"
|
||||
}
|
||||
decodedData[key] = value
|
||||
}
|
||||
|
||||
fun containsDecodedData(key: String?): Boolean {
|
||||
|
|
|
@ -90,7 +90,7 @@ class PumpHistoryEntry : MedtronicHistoryEntry() {
|
|||
// Log.e("", "DT is null. RawData=" + ByteUtil.getHex(rawData))
|
||||
// }
|
||||
sb.append("PumpHistoryEntry [type=" + StringUtil.getStringInLength(entryType.name, 20))
|
||||
sb.append(" " + if (DT == null) "null" else StringUtil.getStringInLength(DT, 19))
|
||||
sb.append(" " + if (dt == null) "null" else StringUtil.getStringInLength(dt, 19))
|
||||
|
||||
val hasData = (decodedData.size > 0)
|
||||
if (hasData) {
|
||||
|
|
|
@ -178,7 +178,7 @@ class MedtronicHistoryData @Inject constructor(
|
|||
for (bolusEstimate in bolusEstimates) {
|
||||
for (bolus in boluses) {
|
||||
if (bolusEstimate.atechDateTime == bolus.atechDateTime) {
|
||||
bolus.addDecodedData("Estimate", bolusEstimate.decodedData["Object"]!!)
|
||||
bolus.addDecodedData("Estimate", bolusEstimate.decodedData.getValue("Object"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1292,15 +1292,15 @@ class MedtronicHistoryData @Inject constructor(
|
|||
|
||||
private fun preProcessTBRs(tbrsInput: MutableList<PumpHistoryEntry>): MutableList<PumpHistoryEntry> {
|
||||
val tbrs: MutableList<PumpHistoryEntry> = mutableListOf()
|
||||
val map: MutableMap<String?, PumpHistoryEntry?> = HashMap()
|
||||
val map: MutableMap<String, PumpHistoryEntry> = HashMap()
|
||||
for (pumpHistoryEntry in tbrsInput) {
|
||||
if (map.containsKey(pumpHistoryEntry.DT)) {
|
||||
medtronicPumpHistoryDecoder.decodeTempBasal(map[pumpHistoryEntry.DT]!!, pumpHistoryEntry)
|
||||
if (map.containsKey(pumpHistoryEntry.dt)) {
|
||||
medtronicPumpHistoryDecoder.decodeTempBasal(map.getValue(pumpHistoryEntry.dateTimeString), pumpHistoryEntry)
|
||||
pumpHistoryEntry.setEntryType(medtronicUtil.medtronicPumpModel, PumpHistoryEntryType.TempBasalCombined)
|
||||
tbrs.add(pumpHistoryEntry)
|
||||
map.remove(pumpHistoryEntry.DT)
|
||||
map.remove(pumpHistoryEntry.dt)
|
||||
} else {
|
||||
map[pumpHistoryEntry.DT] = pumpHistoryEntry
|
||||
map[pumpHistoryEntry.dateTimeString] = pumpHistoryEntry
|
||||
}
|
||||
}
|
||||
return tbrs
|
||||
|
|
|
@ -73,11 +73,11 @@ class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry,
|
|||
fun toTreatmentString(): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
|
||||
stringBuilder.append(itemOne.DT)
|
||||
stringBuilder.append(itemOne.dt)
|
||||
|
||||
if (itemTwo!=null) {
|
||||
stringBuilder.append(" - ")
|
||||
stringBuilder.append(itemTwo?.DT)
|
||||
stringBuilder.append(itemTwo?.dt)
|
||||
}
|
||||
|
||||
stringBuilder.append(" " + durationAsSeconds + " s (" + durationAsSeconds/60 + ")")
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.defs
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net)
|
||||
*
|
||||
|
@ -37,6 +35,7 @@ enum class MedtronicDeviceType {
|
|||
All;
|
||||
|
||||
companion object {
|
||||
|
||||
var mapByDescription: MutableMap<String, MedtronicDeviceType> = mutableMapOf()
|
||||
|
||||
fun isSameDevice(deviceWeCheck: MedtronicDeviceType, deviceSources: MedtronicDeviceType): Boolean {
|
||||
|
@ -50,17 +49,12 @@ enum class MedtronicDeviceType {
|
|||
return false
|
||||
}
|
||||
|
||||
fun getByDescription(desc: String): MedtronicDeviceType {
|
||||
return if (mapByDescription.containsKey(desc)) {
|
||||
mapByDescription[desc]!!
|
||||
} else {
|
||||
Unknown_Device
|
||||
}
|
||||
}
|
||||
fun getByDescription(desc: String): MedtronicDeviceType =
|
||||
mapByDescription[desc] ?: Unknown_Device
|
||||
|
||||
init {
|
||||
for (minimedDeviceType in values()) {
|
||||
if (!minimedDeviceType.isFamily && minimedDeviceType.pumpModel!=null) {
|
||||
if (!minimedDeviceType.isFamily && minimedDeviceType.pumpModel != null) {
|
||||
mapByDescription[minimedDeviceType.pumpModel!!] = minimedDeviceType
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,13 +93,13 @@ open class TestBase {
|
|||
val tbrs: MutableList<PumpHistoryEntry> = mutableListOf()
|
||||
val map: MutableMap<String?, PumpHistoryEntry?> = HashMap()
|
||||
for (pumpHistoryEntry in TBRs_Input) {
|
||||
if (map.containsKey(pumpHistoryEntry.DT)) {
|
||||
decoder.decodeTempBasal(map[pumpHistoryEntry.DT]!!, pumpHistoryEntry)
|
||||
if (map.containsKey(pumpHistoryEntry.dt)) {
|
||||
decoder.decodeTempBasal(map[pumpHistoryEntry.dt]!!, pumpHistoryEntry)
|
||||
pumpHistoryEntry.setEntryType(medtronicUtil.medtronicPumpModel, PumpHistoryEntryType.TempBasalCombined)
|
||||
tbrs.add(pumpHistoryEntry)
|
||||
map.remove(pumpHistoryEntry.DT)
|
||||
map.remove(pumpHistoryEntry.dt)
|
||||
} else {
|
||||
map[pumpHistoryEntry.DT] = pumpHistoryEntry
|
||||
map[pumpHistoryEntry.dt] = pumpHistoryEntry
|
||||
}
|
||||
}
|
||||
return tbrs
|
||||
|
|
|
@ -5,7 +5,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding
|
||||
|
||||
data class PairMessage(
|
||||
class PairMessage(
|
||||
val sequenceNumber: Byte,
|
||||
val source: Id,
|
||||
val destination: Id,
|
||||
|
|
|
@ -101,7 +101,7 @@ class Connection(
|
|||
val discovered = discoverer.discoverServices(connectionWaitCond)
|
||||
val cmdBleIO = CmdBleIO(
|
||||
aapsLogger,
|
||||
discovered[CharacteristicType.CMD]!!,
|
||||
discovered.getValue(CharacteristicType.CMD),
|
||||
incomingPackets
|
||||
.cmdQueue,
|
||||
gatt,
|
||||
|
@ -109,7 +109,7 @@ class Connection(
|
|||
)
|
||||
val dataBleIO = DataBleIO(
|
||||
aapsLogger,
|
||||
discovered[CharacteristicType.DATA]!!,
|
||||
discovered.getValue(CharacteristicType.DATA),
|
||||
incomingPackets
|
||||
.dataQueue,
|
||||
gatt,
|
||||
|
|
|
@ -41,7 +41,7 @@ class Inevitable @Inject internal constructor() {
|
|||
if (debug) {
|
||||
aapsLogger.debug(
|
||||
LTag.WEAR,
|
||||
"Creating task: " + id + " due: " + dateUtil.dateAndTimeAndSecondsString(tasks[id]!!.`when`)
|
||||
"Creating task: " + id + " due: " + dateUtil.dateAndTimeAndSecondsString(tasks.getValue(id).`when`)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ open class WearUtil @Inject constructor(
|
|||
// return true if below rate limit
|
||||
@Synchronized fun isBelowRateLimit(named: String, onceForSeconds: Int): Boolean {
|
||||
// check if over limit
|
||||
if (rateLimits.containsKey(named) && timestamp() - rateLimits[named]!! < onceForSeconds * 1000) {
|
||||
if (rateLimits.containsKey(named) && timestamp() - rateLimits.getValue(named) < onceForSeconds * 1000) {
|
||||
aapsLogger.debug(LTag.WEAR, "$named rate limited to one for $onceForSeconds seconds")
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -2,17 +2,18 @@ package info.nightscout.androidaps.watchfaces.utils
|
|||
|
||||
import android.graphics.DashPathEffect
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.rx.weardata.EventData
|
||||
import info.nightscout.rx.weardata.EventData.SingleBg
|
||||
import info.nightscout.rx.weardata.EventData.TreatmentData.Basal
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import lecho.lib.hellocharts.model.Axis
|
||||
import lecho.lib.hellocharts.model.AxisValue
|
||||
import lecho.lib.hellocharts.model.Line
|
||||
import lecho.lib.hellocharts.model.LineChartData
|
||||
import lecho.lib.hellocharts.model.PointValue
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
import java.util.GregorianCalendar
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
@ -203,7 +204,7 @@ class BgGraphBuilder(
|
|||
if (!values.containsKey(color)) {
|
||||
values[color] = ArrayList()
|
||||
}
|
||||
values[color]!!.add(PointValue(fuzz(timeStamp), value.toFloat()))
|
||||
values.getValue(color).add(PointValue(fuzz(timeStamp), value.toFloat()))
|
||||
}
|
||||
}
|
||||
for ((key, value) in values) {
|
||||
|
|
Loading…
Reference in a new issue