Skip to content

Instantly share code, notes, and snippets.

@hi-manshu
Created January 8, 2021 07:34
Show Gist options
  • Save hi-manshu/80a4f24e84c7a5b8e4b4e55b249695bb to your computer and use it in GitHub Desktop.
Save hi-manshu/80a4f24e84c7a5b8e4b4e55b249695bb to your computer and use it in GitHub Desktop.
@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