Commit 7b5b3f36 authored by Joey's avatar Joey

insulin: cleanup

Signed-off-by: Joey's avatarJoey <bevilacquajoey@gmail.com>
parent bc3588a0
......@@ -14,6 +14,7 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.ArrayAdapter
import android.widget.TextView
import androidx.appcompat.R as Rx
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatEditText
import androidx.appcompat.widget.AppCompatSpinner
......@@ -40,8 +41,7 @@ class EditorActivity : AppCompatActivity() {
private lateinit var saveButton: MaterialButton
private lateinit var deleteButton: MaterialButton
private lateinit var viewModel: it.diab.insulin.viewmodels.EditorViewModel
private lateinit var timeFrames: Array<String>
private lateinit var viewModel: EditorViewModel
private var editMode = false
public override fun onCreate(savedInstance: Bundle?) {
......@@ -64,8 +64,6 @@ class EditorActivity : AppCompatActivity() {
saveButton = view.findViewById(R.id.insulin_edit_save)
deleteButton = view.findViewById(R.id.insulin_edit_delete)
timeFrames = Array(TimeFrame.values().size) { getString(TimeFrame.values()[it].string) }
dialog = BottomSheetDialog(this).apply {
setContentView(view)
setOnDismissListener { finish() }
......@@ -81,9 +79,11 @@ class EditorActivity : AppCompatActivity() {
val uid = intent.getLongExtra(Activities.Insulin.Editor.EXTRA_UID, -1)
editMode = uid >= 0
val timeFrames = Array(TimeFrame.values().size) { getString(TimeFrame.values()[it].string) }
spinner.adapter = ArrayAdapter(
this,
androidx.appcompat.R.layout.support_simple_spinner_dropdown_item,
Rx.layout.support_simple_spinner_dropdown_item,
timeFrames
)
......
......@@ -12,7 +12,7 @@ import androidx.annotation.VisibleForTesting
import it.diab.core.data.entities.Insulin
import it.diab.core.data.repositories.InsulinRepository
import it.diab.core.viewmodels.ScopedViewModel
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class EditorViewModel internal constructor(
......@@ -25,7 +25,7 @@ class EditorViewModel internal constructor(
viewModelScope.launch {
insulin = runSetInsulin(uid)
GlobalScope.launch { block(insulin) }
launch(Dispatchers.Main) { block(insulin) }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment