Skip to content
Permalink
Browse files

Disable the nav drawer when not in a top-level destination.

This prevents the user from being able to swipe out the nav drawer on secondary screens such as session detail or speaker detail. Also, since the map has an entry in the nav graph for both top level and secondary, depending on how the user gets to the map, the drawer may not be swipable. From the top level, it is swipable but if the user lands on the map from a sub-level, then the drawer is locked closed.

Bug: 130387326
Change-Id: I58994b66f638ee84e4c0e4e414553062a4853b06
  • Loading branch information...
benbaxter authored and thagikura committed Apr 16, 2019
1 parent 1c9a2f6 commit 6c69712ccb27f3875c19b9dfcc6946dd52c0e02c
Showing with 7 additions and 0 deletions.
  1. +7 −0 mobile/src/main/java/com/google/samples/apps/iosched/ui/MainActivity.kt
@@ -180,6 +180,13 @@ class MainActivity : DaggerAppCompatActivity(), NavigationHost {
navController = findNavController(R.id.nav_host_fragment)
navController.addOnDestinationChangedListener { _, destination, _ ->
currentNavId = destination.id
val isTopLevelDestination = TOP_LEVEL_DESTINATIONS.contains(destination.id)
val lockMode = if (isTopLevelDestination) {
DrawerLayout.LOCK_MODE_UNLOCKED
} else {
DrawerLayout.LOCK_MODE_LOCKED_CLOSED
}
drawer.setDrawerLockMode(lockMode)
}

navigation = findViewById(R.id.navigation)

0 comments on commit 6c69712

Please sign in to comment.
You can’t perform that action at this time.