Laixer / Swabbr-Android

Swabbr Android application
2 stars 0 forks source link

Correct usage of nav graphs actions #198

Open tabeckers opened 3 years ago

tabeckers commented 3 years ago

Currently our navcontrollers aren't capable of navigating using the created from-to-direction objects. An example would be to go from the WatchVlogFragment to the WatchReactionsForVlogFragment. According to the documentation we should be able to call the following:

findNavController().navigate(WatchVlogFragmentDirections.actionWatchVlogFragmentToWatchReactionsForVlogFragment())

However, this results in an error displaying that our navcontroller doens't know the destination. According to the docs this should be the way to execute our navigation, which often doesn't work.

As a current solution global actions are being used.

tabeckers commented 3 years ago

Other useful info is found in the error message for this specific case:

java.lang.IllegalArgumentException: Navigation action/destination com.laixer.swabbr:id/action_watchVlogFragment_to_watchReactionsForVlogFragment cannot be found from the current destination Destination(com.laixer.swabbr:id/dashboardFragment) label=DashboardFragment class=com.laixer.swabbr.presentation.dashboard.DashboardFragment

Do note that the type of error message stated in the description still occurs at other similar navigation situations.