This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
currentNavController?.value?.addOnDestinationChangedListener { _, destination, _ -> | |
if (mainScreenIds.contains(destination.id)) { | |
bottomNavigation.visibility = View.VISIBLE | |
} else { | |
bottomNavigation.visibility = View.GONE | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onSupportNavigateUp() = currentNavController?.value?.navigateUp(config) ?: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
bottomNavigation = findViewById(R.id.nav_view) | |
val appBarConfiguration = AppBarConfiguration( | |
setOf( | |
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun BottomNavigationView.setupWithNavController( | |
navGraphIds: List<Int>, | |
fragmentManager: FragmentManager, | |
containerId: Int, | |
intent: Intent | |
): LiveData<NavController> { | |
// Map of tags | |
val graphIdToTagMap = SparseArray<String>() | |
// Result. Mutable live data with the selected controlled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Builder for [Preview] that takes in a [WeakReference] of the view finder and | |
* [PreviewConfig], then instantiates a [Preview] which automatically | |
* resizes and rotates reacting to config changes. | |
*/ | |
class AutoFitPreviewBuilder private constructor(config: PreviewConfig, | |
viewFinderRef: WeakReference<TextureView>) { | |
/** Public instance of preview use-case which can be used by consumers of this adapter */ | |
val useCase: Preview |