mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed crash due to nav graph not loaded
This commit is contained in:
parent
10b9044aa8
commit
4ac3649c90
1 changed files with 32 additions and 7 deletions
|
|
@ -372,20 +372,45 @@ class MainActivity : GenericActivity() {
|
|||
if (intent.hasExtra("Chat")) {
|
||||
Log.i("$TAG New intent with [Chat] extra")
|
||||
if (isNewIntent) {
|
||||
Log.i("$TAG Going to Conversations fragment")
|
||||
findNavController().navigate(
|
||||
R.id.action_global_conversationsListFragment,
|
||||
intent.extras
|
||||
)
|
||||
try {
|
||||
val navGraphId = findNavController().graph.id
|
||||
if (navGraphId == R.navigation.main_nav_graph) {
|
||||
Log.i("$TAG Graph is already loaded, going to Conversations fragment")
|
||||
findNavController().navigate(
|
||||
R.id.action_global_conversationsListFragment,
|
||||
intent.extras
|
||||
)
|
||||
} else {
|
||||
Log.i(
|
||||
"$TAG Loading graph & set start destination to Conversations fragment instead of default"
|
||||
)
|
||||
val navGraph = findNavController().navInflater.inflate(
|
||||
R.navigation.main_nav_graph
|
||||
)
|
||||
navGraph.setStartDestination(R.id.conversationsListFragment)
|
||||
findNavController().setGraph(navGraph, intent.extras)
|
||||
}
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.i(
|
||||
"$TAG Nav graph not set yet, loading it & set start destination to Conversations fragment instead of default"
|
||||
)
|
||||
val navGraph = findNavController().navInflater.inflate(
|
||||
R.navigation.main_nav_graph
|
||||
)
|
||||
navGraph.setStartDestination(R.id.conversationsListFragment)
|
||||
findNavController().setGraph(navGraph, intent.extras)
|
||||
}
|
||||
} else {
|
||||
Log.i("$TAG Going to Conversations fragment instead of default destination")
|
||||
Log.i(
|
||||
"$TAG Loading graph & set start destination to Conversations fragment instead of default"
|
||||
)
|
||||
val navGraph = findNavController().navInflater.inflate(R.navigation.main_nav_graph)
|
||||
navGraph.setStartDestination(R.id.conversationsListFragment)
|
||||
findNavController().setGraph(navGraph, intent.extras)
|
||||
}
|
||||
} else {
|
||||
if (!isNewIntent && defaultDestination > 0) {
|
||||
Log.i("$TAG Setting nav graph with expected default destination")
|
||||
Log.i("$TAG Setting nav graph with expected start destination")
|
||||
val navGraph = findNavController().navInflater.inflate(R.navigation.main_nav_graph)
|
||||
navGraph.setStartDestination(defaultDestination)
|
||||
findNavController().setGraph(navGraph, null)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue