lint warnings

This commit is contained in:
Milos Kozak 2019-08-05 16:04:16 +02:00
parent 89d2ff9de8
commit 9608f5185f
4 changed files with 29 additions and 18 deletions

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.aps.loop
import android.os.Bundle
import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -15,6 +14,7 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.HtmlHelper
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
@ -59,6 +59,7 @@ class LoopFragment : Fragment() {
}, {
FabricPrivacy.logException(it)
})
updateGUI()
}
override fun onStop() {
@ -67,18 +68,17 @@ class LoopFragment : Fragment() {
}
fun updateGUI() {
val lastRun = LoopPlugin.lastRun
lastRun?.let {
LoopPlugin.lastRun?.let {
loop_request.text = it.request?.toSpanned() ?: ""
loop_constraintsprocessed.text = it.constraintsProcessed?.toSpanned() ?: ""
loop_source.text = it.source ?: ""
loop_lastrun.text = it.lastAPSRun?.let { lastrun -> DateUtil.dateAndTimeString(lastrun.time) }
loop_lastrun.text = it.lastAPSRun?.let { lastRun -> DateUtil.dateAndTimeString(lastRun.time) }
?: ""
loop_lastenact.text = it.lastAPSRun?.let { lastEnact -> DateUtil.dateAndTimeString(lastEnact.time) }
?: ""
loop_tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> Html.fromHtml(tbrSetByPump.toHtml()) }
loop_tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
?: ""
loop_smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> Html.fromHtml(smbSetByPump.toHtml()) }
loop_smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) }
?: ""
val constraints =
@ -92,7 +92,7 @@ class LoopFragment : Fragment() {
}
}
internal fun clearGUI() {
private fun clearGUI() {
loop_request.text = ""
loop_constraints.text = ""
loop_constraintsprocessed.text = ""

View file

@ -21,10 +21,7 @@ import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolU
import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit
import info.nightscout.androidaps.receivers.ChargingStateReceiver
import info.nightscout.androidaps.receivers.NetworkChangeReceiver
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.SP
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.*
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
@ -44,8 +41,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
private var disposable: CompositeDisposable = CompositeDisposable()
private val listLog = ArrayList<EventTidepoolStatus>()
@Suppress("DEPRECATION") // API level 24 to replace call
var textLog: Spanned = Html.fromHtml("")
var textLog: Spanned = HtmlHelper.fromHtml("")
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
add(disposable)
@ -150,8 +146,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
newTextLog.append(log.toPreparedHtml())
}
}
@Suppress("DEPRECATION") // API level 24 to replace call
textLog = Html.fromHtml(newTextLog.toString())
textLog = HtmlHelper.fromHtml(newTextLog.toString())
} catch (e: OutOfMemoryError) {
ToastUtils.showToastInUiThread(MainApp.instance().applicationContext, "Out of memory!\nStop using this phone !!!", R.raw.error)
}

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.utils
import android.content.Context
import android.content.Intent
import android.text.Html
import androidx.appcompat.app.AlertDialog
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
@ -189,7 +188,8 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
calculatedTotalInsulin = 0.0
}
val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep ?: 0.1
val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep
?: 0.1
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep)
insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(calculatedTotalInsulin)).value()
@ -273,7 +273,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
val builder = AlertDialog.Builder(context)
builder.setTitle(MainApp.gs(R.string.confirmation))
builder.setMessage(Html.fromHtml(confirmMessage))
builder.setMessage(HtmlHelper.fromHtml(confirmMessage))
builder.setPositiveButton(MainApp.gs(R.string.ok)) { _, _ ->
synchronized(builder) {
if (accepted) {

View file

@ -0,0 +1,16 @@
package info.nightscout.androidaps.utils
import android.os.Build
import android.text.Html
import android.text.Spanned
object HtmlHelper {
fun fromHtml(source: String): Spanned {
// API level 24 to replace call
@Suppress("DEPRECATION")
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY)
else -> Html.fromHtml(source)
}
}
}