Skip to content

Instantly share code, notes, and snippets.

View marcinOz's full-sized avatar
💙

Marcin marcinOz

💙
View GitHub Profile
val appModule = module {
// single instance of HelloRepository (which will be reused)
single { HelloRepositoryImpl() }
// Simple Presenter Factory (creates every time new)
factory { MySimplePresenter(get()) }
}
val appModule = module {
// single instance of HelloRepository
singleBy<HelloRepository, HelloRepositoryImpl>()
// Simple Presenter Factory
factory<MySimplePresenter>()
}
override fun onCreate() {
super.onCreate()
// start Koin context
startKoin(this, listOf(appModule))
}
companion object {
fun getComponent(context: Context) =
(context.applicationContext as WTWApplication).appComponent
}
lateinit var appComponent: AppComponent
override fun onCreate() {
super.onCreate()
appComponent = DaggerAppComponent
// Inject MyPresenter
val presenter : MyPresenter by inject()
// A scoped Presenter
module {
scope("activity") { Presenter() }
}
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"))
module {
// Shared user session data
scope("session") { UserSession() }
}
getKoin().createScope("session")
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
)