Skip to content

Instantly share code, notes, and snippets.

@rsajob
Created October 23, 2018 11:52
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 rsajob/66c30873012f033a23bce9ceb739a061 to your computer and use it in GitHub Desktop.
Save rsajob/66c30873012f033a23bce9ceb739a061 to your computer and use it in GitHub Desktop.
Dynamic scopes
private val scopeName: String
get() {
var scopeName = arguments?.getString(ARG_SCOPE_NAME)
if (scopeName == null) {
scopeName = this@ExampleFlowFragmant.objectScopeName()
arguments?.putString(ARG_SCOPE_NAME, scopeName)
initScope(scopeName)
}
return scopeName
}
override fun onCreate(savedInstanceState: Bundle?) {
Toothpick.inject(this, Toothpick.openScope(scopeName))
super.onCreate(savedInstanceState)
if (childFragmentManager.findFragmentById(R.id.ftc_container) == null)
presenter.initFirstScreen(firstScreenInfo)
}
private fun initScope(scopeName:String)
{
Toothpick.openScopes(parentScopeName, scopeName).apply {
installModules(
FlowNavigationModule(scope.getInstance(FlowRouter::class.java), scopeName),
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment