mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-08 17:08:40 +00:00
More View <-> LiveData connection fixes
This commit is contained in:
parent
3b1aae66f3
commit
8effe38a1a
4 changed files with 17 additions and 7 deletions
|
@ -75,6 +75,10 @@ class ViewSiteActivity : AppCompatActivity() {
|
|||
addObserver(statusUpdateReceiver)
|
||||
}
|
||||
|
||||
// Populate view model with initial data
|
||||
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
||||
viewModel.setModel(model)
|
||||
|
||||
// Loading
|
||||
loadingProgress.observe(this, viewModel.onIsLoading())
|
||||
|
||||
|
@ -149,10 +153,6 @@ class ViewSiteActivity : AppCompatActivity() {
|
|||
doneBtn.setOnClickListener {
|
||||
viewModel.commit { finish() }
|
||||
}
|
||||
|
||||
// Populate view model with initial data
|
||||
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
||||
viewModel.setModel(model)
|
||||
}
|
||||
|
||||
private fun setupUi() {
|
||||
|
|
|
@ -38,8 +38,18 @@ inline fun <reified T> EditText.attachLiveData(
|
|||
) {
|
||||
// Initial value
|
||||
if (T::class == String::class) {
|
||||
if (data.value != null) {
|
||||
this.setText(data.value as? String)
|
||||
} else {
|
||||
data.value = this.text.trim().toString() as T
|
||||
}
|
||||
} else if (T::class == Int::class) {
|
||||
if (data.value != null) {
|
||||
this.setText(data.value.toString())
|
||||
} else {
|
||||
data.value = this.text.trim().toString().toInt() as T
|
||||
}
|
||||
}
|
||||
// Out
|
||||
if (pushOutChanges) {
|
||||
when {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue