mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-07 00:18:38 +00:00
Fixed some data population issues
This commit is contained in:
parent
33388bd5c2
commit
0fbd27b54b
2 changed files with 16 additions and 12 deletions
|
@ -84,18 +84,18 @@ class ViewSiteActivity : DarkModeSwitchActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_viewsite)
|
setContentView(R.layout.activity_viewsite)
|
||||||
setupUi()
|
|
||||||
setupValidation()
|
|
||||||
|
|
||||||
lifecycle.run {
|
|
||||||
addObserver(viewModel)
|
|
||||||
addObserver(statusUpdateReceiver)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate view model with initial data
|
// Populate view model with initial data
|
||||||
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
val model = intent.getSerializableExtra(KEY_SITE) as Site
|
||||||
viewModel.setModel(model)
|
viewModel.setModel(model)
|
||||||
|
|
||||||
|
setupUi()
|
||||||
|
setupValidation()
|
||||||
|
lifecycle.run {
|
||||||
|
addObserver(viewModel)
|
||||||
|
addObserver(statusUpdateReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
// Loading
|
// Loading
|
||||||
loadingProgress.observe(this, viewModel.onIsLoading())
|
loadingProgress.observe(this, viewModel.onIsLoading())
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,11 @@ fun ViewSiteViewModel.setModel(site: Site) {
|
||||||
setCheckInterval(settings.validationIntervalMs)
|
setCheckInterval(settings.validationIntervalMs)
|
||||||
setRetryPolicy(site.retryPolicy)
|
setRetryPolicy(site.retryPolicy)
|
||||||
headers.value = site.headers
|
headers.value = site.headers
|
||||||
certificateUri.value = settings.certificate
|
if (settings.certificate == "null") {
|
||||||
|
certificateUri.value = ""
|
||||||
|
} else {
|
||||||
|
certificateUri.value = settings.certificate
|
||||||
|
}
|
||||||
|
|
||||||
this.disabled.value = settings.disabled
|
this.disabled.value = settings.disabled
|
||||||
this.lastResult.value = site.lastResult
|
this.lastResult.value = site.lastResult
|
||||||
|
@ -65,22 +69,22 @@ private fun ViewSiteViewModel.setCheckInterval(interval: Long) {
|
||||||
when {
|
when {
|
||||||
interval >= WEEK -> {
|
interval >= WEEK -> {
|
||||||
checkIntervalValue.value =
|
checkIntervalValue.value =
|
||||||
getIntervalFromUnit(interval, WEEK)
|
getIntervalFromUnit(interval, WEEK)
|
||||||
checkIntervalUnit.value = WEEK
|
checkIntervalUnit.value = WEEK
|
||||||
}
|
}
|
||||||
interval >= DAY -> {
|
interval >= DAY -> {
|
||||||
checkIntervalValue.value =
|
checkIntervalValue.value =
|
||||||
getIntervalFromUnit(interval, DAY)
|
getIntervalFromUnit(interval, DAY)
|
||||||
checkIntervalUnit.value = DAY
|
checkIntervalUnit.value = DAY
|
||||||
}
|
}
|
||||||
interval >= HOUR -> {
|
interval >= HOUR -> {
|
||||||
checkIntervalValue.value =
|
checkIntervalValue.value =
|
||||||
getIntervalFromUnit(interval, HOUR)
|
getIntervalFromUnit(interval, HOUR)
|
||||||
checkIntervalUnit.value = HOUR
|
checkIntervalUnit.value = HOUR
|
||||||
}
|
}
|
||||||
interval >= MINUTE -> {
|
interval >= MINUTE -> {
|
||||||
checkIntervalValue.value =
|
checkIntervalValue.value =
|
||||||
getIntervalFromUnit(interval, MINUTE)
|
getIntervalFromUnit(interval, MINUTE)
|
||||||
checkIntervalUnit.value = MINUTE
|
checkIntervalUnit.value = MINUTE
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue