Skip to content

Instantly share code, notes, and snippets.

@Rasalexman
Created June 24, 2019 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rasalexman/2a9dfe94dfcfa4a376cdff7d3dbeeea1 to your computer and use it in GitHub Desktop.
Save Rasalexman/2a9dfe94dfcfa4a376cdff7d3dbeeea1 to your computer and use it in GitHub Desktop.
abstract class ViewBindController : LifecycleController, KodeinAware {
override val kodein: Kodein by lazy {
(applicationContext as KodeinAware).kodein
}
constructor()
constructor(args: Bundle) : super(args)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val viewInstance = getViewInstance(inflater.context)
onViewCreated(viewInstance)
return viewInstance
}
abstract fun getViewInstance(context: Context):View
abstract fun onViewCreated(view: View)
override fun onDestroyView(view: View) {
(view as? ViewGroup)?.clear()
super.onDestroyView(view)
clearAfterDestroyView<ViewBindController>()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment