Created
March 13, 2022 10:49
-
-
Save addeeandra/3ff2ea049d46248c2020af872171c88f to your computer and use it in GitHub Desktop.
ViewStubBehavior Usage
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
// might be called from Activity.onCreate or Fragment.onViewCreated | |
override fun setupViews() { | |
// setup stub behavior on sales | |
ViewStubBehavior.setup( | |
viewBinding.flSales, | |
viewBinding.stubSales, | |
viewBinding.scrollContainer | |
) { _, view -> | |
val stubBinding = DataBindingUtil.bind<ViewSectionSalesBinding>(view) | |
stubBinding?.lifecycleOwner = this | |
stubBinding?.viewmodel = viewModel | |
stubBinding?.executePendingBindings() | |
viewModel.fetchSales() | |
} | |
// setup stub behavior on inventories | |
ViewStubBehavior.setup( | |
viewBinding.flInventories, | |
viewBinding.stubInventories, | |
viewBinding.scrollContainer | |
) { _, view -> | |
val stubBinding = DataBindingUtil.bind<ViewSectionInventoriesBinding>(view) | |
stubBinding?.lifecycleOwner = this | |
stubBinding?.viewmodel = viewModel | |
stubBinding?.executePendingBindings() | |
viewModel.fetchInventories() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment