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
val appModule = module { | |
// single instance of HelloRepository (which will be reused) | |
single { HelloRepositoryImpl() } | |
// Simple Presenter Factory (creates every time new) | |
factory { MySimplePresenter(get()) } | |
} |
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
val appModule = module { | |
// single instance of HelloRepository | |
singleBy<HelloRepository, HelloRepositoryImpl>() | |
// Simple Presenter Factory | |
factory<MySimplePresenter>() | |
} |
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
override fun onCreate() { | |
super.onCreate() | |
// start Koin context | |
startKoin(this, listOf(appModule)) | |
} |
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
companion object { | |
fun getComponent(context: Context) = | |
(context.applicationContext as WTWApplication).appComponent | |
} | |
lateinit var appComponent: AppComponent | |
override fun onCreate() { | |
super.onCreate() | |
appComponent = DaggerAppComponent |
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
// Inject MyPresenter | |
val presenter : MyPresenter by inject() |
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
// A scoped Presenter | |
module { | |
scope("activity") { Presenter() } | |
} |
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
class MyActivity : AppCompatActivity() { | |
// inject Presenter instance, tied to current MyActivity's scope | |
val presenter : Presenter by inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// bind current lifecycle to Activity's scope | |
bindScope(createScope("activity")) |
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
module { | |
// Shared user session data | |
scope("session") { UserSession() } | |
} |
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
getKoin().createScope("session") |
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
add_library( # Sets the name of the library. | |
native-lib | |
# Sets the library as a shared library. | |
SHARED | |
# Provides a relative path to your source file(s). | |
src/main/cpp/native-lib.cpp | |
../../Shared/SheetDetection.cpp | |
) |