0

I'm setting a conditional startDestination, as e.g. seen here:

https://stackoverflow.com/a/51961843/393607

The problem: The condition should depend on a room query. This query can't be run on the main thread of course, the onCreate of the MainActivity would have to wait for the query to be finished before constructing the navigation graph.

Any recommendations on how to go about this?

ThemBones
  • 357
  • 1
  • 11

1 Answers1

0

Ok that was fast. Kotlin's really great: wrapping everything in runBlocking {} did the trick. I'll leave this here, in case somebody needs it.

ThemBones
  • 357
  • 1
  • 11
  • doesn't that freeze the ui thread for the duration of the query? – EpicPandaForce Jun 21 '19 at 16:02
  • I guess so, but I need to determine which fragment is the start fragment, so there's no ui yet whatsoever. Also, it's a count query on a very small table so I assume it's ok to do it. – ThemBones Jun 21 '19 at 16:10