Created
January 8, 2021 07:34
-
-
Save hi-manshu/80a4f24e84c7a5b8e4b4e55b249695bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @ExperimentalCoroutinesApi | |
| abstract class IBaseFragment<VB : ViewBinding, VM : IBaseViewModel> : Fragment() { | |
| protected abstract val viewModel: VM | |
| lateinit var binding: VB | |
| override fun onCreateView( | |
| inflater: LayoutInflater, | |
| container: ViewGroup?, | |
| savedInstanceState: Bundle? | |
| ): View? { | |
| binding = getViewBinding(inflater) | |
| setupView() | |
| setupObserver() | |
| return binding.root | |
| } | |
| abstract fun getViewBinding(inflater: LayoutInflater): VB | |
| fun goBack() { | |
| requireActivity().onBackPressed() | |
| } | |
| protected abstract fun setupObserver() | |
| protected abstract fun setupView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment