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
val databaseModule = Kodein.Module("database_module") { | |
bind<IGenresDao>() with provider { kodein.direct.instance<MoviesDatabase>().getGenresDao() } | |
bind<IMoviesDao>() with provider { kodein.direct.instance<MoviesDatabase>().getMoviesDao() } | |
} |
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
class MainApplication : Application(), KodeinAware { | |
override val kodein: Kodein by Kodein.lazy { | |
bind<ViewModelFactory>() with singleton { ViewModelFactory(applicationContext) } | |
bind<MoviesDatabase>() with singleton { | |
Room.databaseBuilder( | |
applicationContext, | |
MoviesDatabase::class.java, "moviesDB" | |
).build() | |
} |
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
class ViewModelFactory(appContext:Context) : ViewModelProvider.Factory, KodeinAware { | |
override val kodein: Kodein = (appContext as MainApplication).kodein // we can use `by kodein(appContext)` also | |
override fun <T : ViewModel> create(modelClass: Class<T>): T = kodein.direct.Instance(TT(modelClass)) | |
} |
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
val databaseModule = Kodein.Module("database_module") { | |
bind<IGenresDao>() with provider { kodein.direct.instance<MoviesDatabase>().getGenresDao() } | |
bind<IMoviesDao>() with provider { kodein.direct.instance<MoviesDatabase>().getMoviesDao() } | |
} |
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
val databaseModule = Kodein.Module("database_module") { | |
bind<IGenresDao>() with provider { kodein.direct.instance<MoviesDatabase>().getGenresDao() } | |
bind<IMoviesDao>() with provider { kodein.direct.instance<MoviesDatabase>().getMoviesDao() } | |
} |
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
class MainApplication : Application(), KodeinAware { | |
override val kodein: Kodein by Kodein.lazy { | |
bind<ViewModelFactory>() with singleton { ViewModelFactory(applicationContext) } | |
bind<MoviesDatabase>() with singleton { | |
Room.databaseBuilder( | |
applicationContext, | |
MoviesDatabase::class.java, "moviesDB" | |
).build() | |
} |
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
class ViewModelFactory(appContext:Context) : ViewModelProvider.Factory, KodeinAware { | |
override val kodein: Kodein = (appContext as MainApplication).kodein // we can use `by kodein(appContext)` also | |
override fun <T : ViewModel> create(modelClass: Class<T>): T = kodein.direct.Instance(TT(modelClass)) | |
} |
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
class ViewModelFactory(appContext: Context) : ViewModelProvider.Factory, KodeinAware { | |
override val kodein: Kodein = (appContext as MainApplication).kodein // we can use `by kodein(appContext)` also | |
override fun <T : ViewModel> create(modelClass: Class<T>): T = kodein.direct.Instance(TT(modelClass)) | |
} |
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
val databaseModule = Kodein.Module("database_module") { | |
bind<IGenresDao>() with provider { instance<MoviesDatabase>().getGenresDao() } | |
bind<IMoviesDao>() with provider { instance<MoviesDatabase>().getMoviesDao() } | |
} |
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) |
OlderNewer