Fixed state not being propagated correctly on startup
This commit is contained in:
parent
34a0a00e3c
commit
89da45f9ac
@ -129,6 +129,14 @@ object UpdateChannelUrl : SettingsItem.Input() {
|
||||
notifyChange(BR.result)
|
||||
}
|
||||
|
||||
init {
|
||||
updateState()
|
||||
}
|
||||
|
||||
fun updateState() {
|
||||
isEnabled = UpdateChannel.value == Config.Value.CUSTOM_CHANNEL
|
||||
}
|
||||
|
||||
override fun getView(context: Context) = DialogSettingsUpdateChannelBinding
|
||||
.inflate(LayoutInflater.from(context)).also { it.data = this }.root
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import androidx.databinding.Bindable
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.topjohnwu.magisk.BR
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.model.entity.recycler.ObservableItem
|
||||
import com.topjohnwu.magisk.model.events.DieEvent
|
||||
@ -49,19 +48,15 @@ class SettingsViewModel : CompatViewModel(), SettingsItem.Callback {
|
||||
// use only instances you want, don't declare everything
|
||||
is Theme -> Navigation.theme().publish()
|
||||
is Redesign -> DieEvent().publish()
|
||||
is UpdateChannel -> item.openUrlIfNecessary(view)
|
||||
is UpdateChannel -> openUrlIfNecessary(view)
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
private fun UpdateChannel.openUrlIfNecessary(view: View) {
|
||||
if (value == Config.Value.CUSTOM_CHANNEL) {
|
||||
private fun openUrlIfNecessary(view: View) {
|
||||
UpdateChannelUrl.updateState()
|
||||
if (UpdateChannelUrl.value.isBlank()) {
|
||||
UpdateChannelUrl.onPressed(view, this@SettingsViewModel)
|
||||
}
|
||||
UpdateChannelUrl.isEnabled = true
|
||||
} else {
|
||||
UpdateChannelUrl.isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user