Status Update
Comments
yb...@google.com <yb...@google.com>
fa...@gmail.com <fa...@gmail.com> #2
this would be nice but given Compose and all other priorities, we are not planning to make any big investments in data binding (support KSP is a very big task).
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #3
Makes sense. And is there any way to trigger data binding without kapt plugin, assuming there are no custom binding adapters in given module?
yb...@google.com <yb...@google.com>
sh...@google.com <sh...@google.com>
sh...@google.com <sh...@google.com> #4
unfortunately no. data binding still needs to be able to read your code and annotation processing is the only API that allows us to do it :(
sh...@google.com <sh...@google.com>
yb...@google.com <yb...@google.com> #5
It's a very disappointing decision for many projects who heavily depend on data binding, which will never be able to get rid of all bindings code and especially rewrite all UI to Compose.
It means that bindings are essentially deprecated
yb...@google.com <yb...@google.com>
va...@gmail.com <va...@gmail.com> #6
It does not mean data binding is deprecated unless KAPT is deprecated (if that happens, we would need to support KSP).Unfortunately, moving data binding to KSP is a large order so it makes more sense to keep focusing on KAPT than rewrite data binding.
We might re-consider this in the future based on KSP becoming stable, Compose adoption and KAPT stability but it is very unlikely to happen.
Description
Version used: 1.0.0-alpha9
Devices/Android versions reproduced on: Android 5 (it works on Android 8)
I have a strange problem connected to a MutableLiveData that doesn't trigger the observer when updated in onActivityResult. The cause seems to be a wrong state in LifecycleRegistry, in the following example the println in onResume prints "resume CREATED". Between startActivityForResult and onResume the state is set to CREATED even if the Activity remains always started (because the other activity is not full screen).
You can reproduce this issue using this Activity:
class LiveDataTestActivity : AppCompatActivity(), LifecycleRegistryOwner {
private val lifecycle = LifecycleRegistry(this)
override fun getLifecycle() = lifecycle
private val myLiveData = MutableLiveData<Int>().apply { value = 0 }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val textView = TextView(this).apply {
text = "AAAA"
setOnClickListener {
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
type = "text/plain"
}
startActivityForResult(sendIntent, 123)
}
}
setContentView(textView)
myLiveData.observe(this, Observer<Int> {
textView.text = it.toString()
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
myLiveData.value = (myLiveData.value ?: 0) + 1
println("Value ${myLiveData.value}")
}
override fun onResume() {
super.onResume()
println("resume ${lifecycle.currentState}")
}
}