Created
June 24, 2019 20:30
-
-
Save Rasalexman/2a9dfe94dfcfa4a376cdff7d3dbeeea1 to your computer and use it in GitHub Desktop.
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
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