Skip to content

Instantly share code, notes, and snippets.

View yevhenRoman's full-sized avatar
💭
writing code

yevhenRoman

💭
writing code
View GitHub Profile
currentNavController?.value?.addOnDestinationChangedListener { _, destination, _ ->
if (mainScreenIds.contains(destination.id)) {
bottomNavigation.visibility = View.VISIBLE
} else {
bottomNavigation.visibility = View.GONE
}
}
override fun onSupportNavigateUp() = currentNavController?.value?.navigateUp(config) ?: false
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
)
)
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
/**
* 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