mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-08 08:58:41 +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)
|
addObserver(statusUpdateReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate view model with initial data
|
||||||
|
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
||||||
|
viewModel.setModel(model)
|
||||||
|
|
||||||
// Loading
|
// Loading
|
||||||
loadingProgress.observe(this, viewModel.onIsLoading())
|
loadingProgress.observe(this, viewModel.onIsLoading())
|
||||||
|
|
||||||
|
@ -149,10 +153,6 @@ class ViewSiteActivity : AppCompatActivity() {
|
||||||
doneBtn.setOnClickListener {
|
doneBtn.setOnClickListener {
|
||||||
viewModel.commit { finish() }
|
viewModel.commit { finish() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate view model with initial data
|
|
||||||
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
|
||||||
viewModel.setModel(model)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUi() {
|
private fun setupUi() {
|
||||||
|
|
|
@ -228,7 +228,7 @@ class ViewSiteViewModelTest {
|
||||||
text.assertValues(TEXT_CHECKS_DISABLED)
|
text.assertValues(TEXT_CHECKS_DISABLED)
|
||||||
|
|
||||||
viewModel.disabled.value = false
|
viewModel.disabled.value = false
|
||||||
text.assertValues("December 6, 8:35AM")
|
text.assertValues("December 6, 8:35 AM")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun getCheckIntervalMs() {
|
@Test fun getCheckIntervalMs() {
|
||||||
|
|
|
@ -23,6 +23,6 @@ fun Long.formatDate(): String {
|
||||||
if (this <= 0) {
|
if (this <= 0) {
|
||||||
return "(None)"
|
return "(None)"
|
||||||
}
|
}
|
||||||
val df = SimpleDateFormat("MMMM d, h:mma", Locale.getDefault())
|
val df = SimpleDateFormat("MMMM d, h:mm a", Locale.getDefault())
|
||||||
return df.format(Date(this))
|
return df.format(Date(this))
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,17 @@ inline fun <reified T> EditText.attachLiveData(
|
||||||
) {
|
) {
|
||||||
// Initial value
|
// Initial value
|
||||||
if (T::class == String::class) {
|
if (T::class == String::class) {
|
||||||
data.value = this.text.trim().toString() as T
|
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
|
// Out
|
||||||
if (pushOutChanges) {
|
if (pushOutChanges) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue