chore: fix code smells
This commit is contained in:
parent
f0076ed0dd
commit
0200e93677
6 changed files with 22 additions and 26 deletions
|
@ -697,10 +697,10 @@ class DataHandlerMobile @Inject constructor(
|
||||||
bolusPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100),
|
bolusPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100),
|
||||||
maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48),
|
maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48),
|
||||||
maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0),
|
maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0),
|
||||||
insulin_button_increment_1 = sp.getDouble(R.string.key_insulin_button_increment_1, InsulinDialog.PLUS1_DEFAULT),
|
insulinButtonIncrement1 = sp.getDouble(R.string.key_insulin_button_increment_1, InsulinDialog.PLUS1_DEFAULT),
|
||||||
insulin_button_increment_2 = sp.getDouble(R.string.key_insulin_button_increment_2, InsulinDialog.PLUS2_DEFAULT),
|
insulinButtonIncrement2 = sp.getDouble(R.string.key_insulin_button_increment_2, InsulinDialog.PLUS2_DEFAULT),
|
||||||
carbs_button_increment_1 = sp.getInt(R.string.key_carbs_button_increment_1, CarbsDialog.FAV1_DEFAULT),
|
carbsButtonIncrement1 = sp.getInt(R.string.key_carbs_button_increment_1, CarbsDialog.FAV1_DEFAULT),
|
||||||
carbs_button_increment_2 = sp.getInt(R.string.key_carbs_button_increment_2, CarbsDialog.FAV2_DEFAULT)
|
carbsButtonIncrement2 = sp.getInt(R.string.key_carbs_button_increment_2, CarbsDialog.FAV2_DEFAULT)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -209,10 +209,10 @@ sealed class EventData : Event() {
|
||||||
val bolusPercentage: Int,
|
val bolusPercentage: Int,
|
||||||
val maxCarbs: Int,
|
val maxCarbs: Int,
|
||||||
val maxBolus: Double,
|
val maxBolus: Double,
|
||||||
val insulin_button_increment_1: Double,
|
val insulinButtonIncrement1: Double,
|
||||||
val insulin_button_increment_2: Double,
|
val insulinButtonIncrement2: Double,
|
||||||
val carbs_button_increment_1: Int,
|
val carbsButtonIncrement1: Int,
|
||||||
val carbs_button_increment_2: Int
|
val carbsButtonIncrement2: Int
|
||||||
) : EventData()
|
) : EventData()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
|
@ -162,10 +162,10 @@ class DataHandlerWear @Inject constructor(
|
||||||
sp.putInt(R.string.key_bolus_wizard_percentage, it.bolusPercentage)
|
sp.putInt(R.string.key_bolus_wizard_percentage, it.bolusPercentage)
|
||||||
sp.putInt(R.string.key_treatments_safety_max_carbs, it.maxCarbs)
|
sp.putInt(R.string.key_treatments_safety_max_carbs, it.maxCarbs)
|
||||||
sp.putDouble(R.string.key_treatments_safety_max_bolus, it.maxBolus)
|
sp.putDouble(R.string.key_treatments_safety_max_bolus, it.maxBolus)
|
||||||
sp.putDouble(R.string.key_insulin_button_increment_1, it.insulin_button_increment_1)
|
sp.putDouble(R.string.key_insulin_button_increment_1, it.insulinButtonIncrement1)
|
||||||
sp.putDouble(R.string.key_insulin_button_increment_2, it.insulin_button_increment_2)
|
sp.putDouble(R.string.key_insulin_button_increment_2, it.insulinButtonIncrement2)
|
||||||
sp.putInt(R.string.key_carbs_button_increment_1, it.carbs_button_increment_1)
|
sp.putInt(R.string.key_carbs_button_increment_1, it.carbsButtonIncrement1)
|
||||||
sp.putInt(R.string.key_carbs_button_increment_2, it.carbs_button_increment_2)
|
sp.putInt(R.string.key_carbs_button_increment_2, it.carbsButtonIncrement2)
|
||||||
}
|
}
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventData.QuickWizard::class.java)
|
.toObservable(EventData.QuickWizard::class.java)
|
||||||
|
|
|
@ -74,7 +74,6 @@ class TempTargetActivity : ViewSelectorActivity() {
|
||||||
if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString())
|
if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString())
|
||||||
lowRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title)
|
lowRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
container.addView(view)
|
container.addView(view)
|
||||||
view
|
view
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.databinding.ActionEditplusminViktoriaBinding
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EditPlusMinusViewAdapter binds both ActionEditplusminusItemBinding variants shared attributes to one common view adapter.
|
* EditPlusMinusViewAdapter binds both ActionEditplusminBinding variants shared attributes to one common view adapter.
|
||||||
* Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding.
|
* Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding.
|
||||||
*/
|
*/
|
||||||
class EditPlusMinusViewAdapter(
|
class EditPlusMinusViewAdapter(
|
||||||
|
@ -32,28 +32,28 @@ class EditPlusMinusViewAdapter(
|
||||||
throw IllegalArgumentException("Require at least on Binding parameter")
|
throw IllegalArgumentException("Require at least on Binding parameter")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private val errorMessage = "Missing require View Binding parameter"
|
||||||
val editText =
|
val editText =
|
||||||
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
|
eD?.editText ?: eDP?.editText ?: eQL?.editText ?: eQLP?.editText ?: eQR?.editText ?: eQRP?.editText ?: eV?.editText
|
||||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
?: throw IllegalArgumentException(errorMessage)
|
||||||
val minButton =
|
val minButton =
|
||||||
eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton
|
eD?.minButton ?: eDP?.minButton ?: eQL?.minButton ?: eQLP?.minButton ?: eQR?.minButton ?: eQRP?.minButton ?: eV?.minButton
|
||||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
?: throw IllegalArgumentException(errorMessage)
|
||||||
val plusButton1 =
|
val plusButton1 =
|
||||||
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
|
eD?.plusButton1 ?: eDP?.plusButton1 ?: eQL?.plusButton1 ?: eQLP?.plusButton1 ?: eQR?.plusButton1 ?: eQRP?.plusButton1 ?: eV?.plusButton1
|
||||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
?: throw IllegalArgumentException(errorMessage)
|
||||||
val label =
|
val label =
|
||||||
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
|
eD?.label ?: eDP?.label ?: eQL?.label ?: eQLP?.label ?: eQR?.label ?: eQRP?.label ?: eV?.label
|
||||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
?: throw IllegalArgumentException(errorMessage)
|
||||||
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
|
val plusButton2 = eDP?.plusButton2 ?: eQLP?.plusButton2 ?: eQRP?.plusButton2
|
||||||
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
|
val plusButton3 = eDP?.plusButton3 ?: eQLP?.plusButton3 ?: eQRP?.plusButton3
|
||||||
val root =
|
val root =
|
||||||
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
|
eD?.root ?: eDP?.root ?: eQL?.root ?: eQLP?.root ?: eQR?.root ?: eQRP?.root ?: eV?.root
|
||||||
?: throw IllegalArgumentException("Missing require View Binding parameter display")
|
?: throw IllegalArgumentException(errorMessage)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup?, multiple: Boolean = false): EditPlusMinusViewAdapter {
|
fun getViewAdapter(sp: SP, context: Context, container: ViewGroup, multiple: Boolean = false): EditPlusMinusViewAdapter {
|
||||||
val inflater = LayoutInflater.from(context)
|
val inflater = LayoutInflater.from(context)
|
||||||
|
|
||||||
return when (sp.getInt(R.string.key_input_design, 1)) {
|
return when (sp.getInt(R.string.key_input_design, 1)) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.*
|
import android.os.*
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
@ -20,7 +19,7 @@ import java.util.concurrent.TimeUnit
|
||||||
/**
|
/**
|
||||||
* Created by mike on 28.06.2016.
|
* Created by mike on 28.06.2016.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("SetTextI18n") class PlusMinusEditText @JvmOverloads constructor(
|
class PlusMinusEditText @JvmOverloads constructor(
|
||||||
private val binding: EditPlusMinusViewAdapter,
|
private val binding: EditPlusMinusViewAdapter,
|
||||||
initValue: Double,
|
initValue: Double,
|
||||||
private val minValue: Double,
|
private val minValue: Double,
|
||||||
|
@ -106,9 +105,7 @@ import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
private fun vibrateDevice() {
|
private fun vibrateDevice() {
|
||||||
val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
val vibratorManager =
|
(binding.root.context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator
|
||||||
binding.root.context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
|
|
||||||
vibratorManager.defaultVibrator
|
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
binding.root.context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
binding.root.context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||||
|
|
Loading…
Reference in a new issue