mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-04-20 03:25:14 +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() {
|
||||
|
|
|
@ -228,7 +228,7 @@ class ViewSiteViewModelTest {
|
|||
text.assertValues(TEXT_CHECKS_DISABLED)
|
||||
|
||||
viewModel.disabled.value = false
|
||||
text.assertValues("December 6, 8:35AM")
|
||||
text.assertValues("December 6, 8:35 AM")
|
||||
}
|
||||
|
||||
@Test fun getCheckIntervalMs() {
|
||||
|
|
|
@ -23,6 +23,6 @@ fun Long.formatDate(): String {
|
|||
if (this <= 0) {
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -38,7 +38,17 @@ inline fun <reified T> EditText.attachLiveData(
|
|||
) {
|
||||
// Initial value
|
||||
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
|
||||
if (pushOutChanges) {
|
||||
|
|
Loading…
Add table
Reference in a new issue