Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
The problem is reproducible using support lib 26.1.0, this is the updated activity:
class LiveDataTestActivity : AppCompatActivity() {
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}")
}
}
class LiveDataTestActivity : AppCompatActivity() {
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}")
}
}
Description
Version used: 1.0.0-alpha01
When using a global action (an action attached to a <navigation> element), all of the destinations under that <navigation> element should extend the <navigation> element's Directions class. This ensures that the final Directions object contains all of the valid actions from that destination on all levels of the navigation graph.
For example:
<navigation
xmlns:android="
xmlns:app="
app:startDestination="@id/main_fragment">
<fragment
android:id="@+id/main_fragment"
android:name=".MainFragment">
<action
android:id="@+id/start_login"
app:destination="@id/login"/>
</fragment>
<navigation
android:id="@+id/login"
app:startDestination="@id/login_fragment">
<action
android:id="@+id/action_done"
app:popUpTo="@id/main_fragment"/>
<fragment
android:id="@+id/login_fragment"
android:name=".LoginFragment">
<action
android:id="@+id/register"
app:destination="@id/register_fragment"/>
</fragment>
<fragment
android:id="@+id/register_fragment"
android:name=".RegisterFragment">
</fragment>
</navigation>
</navigation>
There should be
- A LoginDirections class that has an action_done() method (this works right now).
- A LoginFragmentDirections class that extends LoginDirections (currently it does not extend anything)
- An empty RegisterFragmentDirections class that extends LoginDirections (currently it does not exist)