Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class BaseFragment<VB: ViewBinding> : Fragment() {
- abstract val inflate: Inflate<VB>
- protected var binding: VB? = null
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- binding = inflate.invoke(inflater, container, false)
- return binding?.root
- }
- override fun onDestroyView() {
- super.onDestroyView()
- binding = null
- }
- }
- //
- class CategoriesFragment : BaseFragment<FragmentCategoriesBinding>() {
- private val viewModel by inject<CategoriesVM>()
- override val inflate: Inflate<FragmentCategoriesBinding> = FragmentCategoriesBinding::inflate
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- binding?.apply {
- titleTV.text = "Категории"
- }
- }
- companion object {
- fun newInstance() = CategoriesFragment()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement