Commit 726ddcfd authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

resolve singleton component dependencies

parent 438b5ce5
...@@ -62,7 +62,7 @@ class AlbumsContractModule @Inject constructor( ...@@ -62,7 +62,7 @@ class AlbumsContractModule @Inject constructor(
private fun fetchTopLevelAlbums(): Observable<List<AlbumPreviewModel>> = private fun fetchTopLevelAlbums(): Observable<List<AlbumPreviewModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchTopLevelAlbumsApi,fetchTopLevelAlbumsDb) arrayListOf(fetchTopLevelAlbumsApi,fetchTopLevelAlbumsDb)
).take(1).map { fromEntity(it,::fromEntity) } ).map { fromEntity(it,::fromEntity) }
private fun fetchAlbumsApi(parentAlbumId:Int) = private fun fetchAlbumsApi(parentAlbumId:Int) =
...@@ -92,7 +92,7 @@ class AlbumsContractModule @Inject constructor( ...@@ -92,7 +92,7 @@ class AlbumsContractModule @Inject constructor(
private fun fetchAlbums(parentId:Int): Observable<List<AlbumPreviewModel>> = private fun fetchAlbums(parentId:Int): Observable<List<AlbumPreviewModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchAlbumsApi(parentId),fetchAlbumsDb(parentId)) arrayListOf(fetchAlbumsApi(parentId),fetchAlbumsDb(parentId))
).take(1).map { fromEntity(it,::fromEntity) } ).map { fromEntity(it,::fromEntity) }
} }
...@@ -80,7 +80,7 @@ class FeedsContractModule @Inject constructor( ...@@ -80,7 +80,7 @@ class FeedsContractModule @Inject constructor(
).take(1).map { fromEntity(feedId,it) } ).take(1).map { fromEntity(feedId,it) }
private fun fetchFeedsApi() = private val fetchFeedsApi =
api.getFeeds() api.getFeeds()
.doOnNext { Timber.d("raw0 $it") } .doOnNext { Timber.d("raw0 $it") }
.map{fromRawList(it,::fromRaw)} .map{fromRawList(it,::fromRaw)}
...@@ -95,7 +95,7 @@ class FeedsContractModule @Inject constructor( ...@@ -95,7 +95,7 @@ class FeedsContractModule @Inject constructor(
fun fetchAllFeeds(): Observable<List<FeedModel>> = fun fetchAllFeeds(): Observable<List<FeedModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchFeedsApi(),fetchFeedsDb) arrayListOf(fetchFeedsApi,fetchFeedsDb)
).map { fromEntity(it,::fromEntity) } ).map { fromEntity(it,::fromEntity) }
} }
......
package com.biganto.visual.roompark.data.local package com.biganto.visual.roompark.data.local
import android.app.Application import android.app.Application
import android.content.Context
import com.afollestad.rxkprefs.Pref import com.afollestad.rxkprefs.Pref
import com.afollestad.rxkprefs.rxkPrefs import com.afollestad.rxkprefs.rxkPrefs
import com.biganto.visual.androidplayer.data.repository.local.ILocalStore import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
...@@ -30,7 +29,7 @@ class LocalStorage(){ ...@@ -30,7 +29,7 @@ class LocalStorage(){
fun provideStore(app : Application):ILocalStore = UserHolder(app) fun provideStore(app : Application):ILocalStore = UserHolder(app)
} }
class UserHolder @Inject constructor(val context : Context) : ILocalStore class UserHolder @Inject constructor(val context : Application) : ILocalStore
{ {
init { init {
Timber.d(" inited") Timber.d(" inited")
......
...@@ -23,6 +23,10 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi ...@@ -23,6 +23,10 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
private val api = retrofit.create(IRoomParkMobileApi::class.java) private val api = retrofit.create(IRoomParkMobileApi::class.java)
init {
Timber.d("Module inited")
}
override fun authenticate(login: String, pwd: String): Observable<AuthRaw> = override fun authenticate(login: String, pwd: String): Observable<AuthRaw> =
api.authoriz(email = login, pwd = pwd) api.authoriz(email = login, pwd = pwd)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
...@@ -118,7 +122,7 @@ enum class PlanTypeCatalog(val planId:Int, val planName:String ){ ...@@ -118,7 +122,7 @@ enum class PlanTypeCatalog(val planId:Int, val planName:String ){
internal class RetrofitResponseValidation<T> : ObservableTransformer<Response<T>, T> { internal class RetrofitResponseValidation<T> : ObservableTransformer<Response<T>, T> {
override fun apply(responseObservable: Observable<Response<T>>): ObservableSource<T> { override fun apply(responseObservable: Observable<Response<T>>): ObservableSource<T> {
return responseObservable.switchMap { resp -> return responseObservable.switchMap { resp ->
// Timber.d("reutrned code: %s",resp.code()) Timber.d("reutrned code: %s",resp.code())
if (resp.code() == 200 || resp.code() == 206) if (resp.code() == 200 || resp.code() == 206)
if (resp.body() == null) if (resp.body() == null)
return@switchMap Completable.complete().toObservable<T>().doOnNext{ Timber.d("Completed responseBody")} return@switchMap Completable.complete().toObservable<T>().doOnNext{ Timber.d("Completed responseBody")}
......
package com.biganto.visual.roompark.data.repository.api.retrofit.di package com.biganto.visual.roompark.data.repository.api.retrofit.di
import android.content.Context import android.app.Application
import com.biganto.visual.roompark.data.repository.api.retrofit.IRoomParkMobileApi import com.biganto.visual.roompark.data.repository.api.retrofit.IRoomParkMobileApi
import com.biganto.visual.roompark.data.repository.api.retrofit.raw.ErrorRaw import com.biganto.visual.roompark.data.repository.api.retrofit.raw.ErrorRaw
import com.biganto.visual.roompark.data.repository.api.retrofit.util.* import com.biganto.visual.roompark.data.repository.api.retrofit.util.*
...@@ -40,6 +40,10 @@ class RetrofitModule{ ...@@ -40,6 +40,10 @@ class RetrofitModule{
// //
// var versionControl = AppVersionManager(context) // var versionControl = AppVersionManager(context)
init {
Timber.d("Module inited")
}
private inline fun <reified T> genericType() = object : TypeToken<T>() {}.type private inline fun <reified T> genericType() = object : TypeToken<T>() {}.type
private fun gsonConverterFactory() = GsonConverterFactory.create( private fun gsonConverterFactory() = GsonConverterFactory.create(
...@@ -96,7 +100,7 @@ class RetrofitModule{ ...@@ -96,7 +100,7 @@ class RetrofitModule{
@Provides @Provides
@Singleton @Singleton
// @Named("roomParkApi") // @Named("roomParkApi")
fun provideRetrofitRoomParkApi(context: Context): Retrofit = fun provideRetrofitRoomParkApi(context: Application): Retrofit =
Retrofit.Builder() Retrofit.Builder()
.baseUrl(IRoomParkMobileApi.BASE_URL) .baseUrl(IRoomParkMobileApi.BASE_URL)
.client(client(AppVersionManager(context), LiveNetworkMonitor(context))) .client(client(AppVersionManager(context), LiveNetworkMonitor(context)))
......
package com.biganto.visual.roompark.data.repository.db.requrey package com.biganto.visual.roompark.data.repository.db.requrey
import android.content.Context import android.app.Application
import com.biganto.visual.roompark.data.repository.db.IDb import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.model.* import com.biganto.visual.roompark.data.repository.db.requrey.model.*
import com.biganto.visual.roompark.di.dagger.DATABASE_VERSION import com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
...@@ -26,7 +26,7 @@ import javax.inject.Inject ...@@ -26,7 +26,7 @@ import javax.inject.Inject
class DbModule{ class DbModule{
@Provides @Provides
fun provideStore(context: Context): KotlinReactiveEntityStore<Persistable> { fun provideStore(context: Application): KotlinReactiveEntityStore<Persistable> {
Timber.d("Kotlin store creating..") Timber.d("Kotlin store creating..")
val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION) val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION)
......
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.data.local.LocalStorage import com.biganto.visual.roompark.data.local.LocalStorage
import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.domain.contract.AuthContract import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.contract.DevProgressContract
import com.biganto.visual.roompark.domain.contract.FeedsContract
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
...@@ -33,13 +38,26 @@ import javax.inject.Singleton ...@@ -33,13 +38,26 @@ import javax.inject.Singleton
AndroidSupportInjectionModule::class, AndroidSupportInjectionModule::class,
// MappingProvider::class, // MappingProvider::class,
ActivityModule::class, ActivityModule::class,
// ContractRepositoryModule::class, ContractRepositoryModule::class,
AppActivityModule ::class]) AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun authC():AuthContract fun authC():AuthContract
fun feedsC():FeedsContract
fun feedsAlb(): DevProgressContract
fun provideLocal():ILocalStore
fun provideApi():IRoomParkApi
fun providedb():IDb
@Component.Factory @Component.Factory
interface Factory{ interface Factory{
......
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import com.biganto.visual.roompark.data.data_provider.AlbumsContractModule
import com.biganto.visual.roompark.data.data_provider.AuthContractModule
import com.biganto.visual.roompark.data.data_provider.FeedsContractModule
import com.biganto.visual.roompark.data.local.LocalStorage
import com.biganto.visual.roompark.data.repository.api.IRoomParkApi import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.api.retrofit.RetrofitRepository import com.biganto.visual.roompark.data.repository.api.retrofit.RetrofitRepository
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.IDb import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.data.repository.db.requrey.RequeryRepository import com.biganto.visual.roompark.data.repository.db.requrey.RequeryRepository
import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.contract.DevProgressContract
import com.biganto.visual.roompark.domain.contract.FeedsContract
import dagger.Binds import dagger.Binds
import dagger.Component import dagger.Component
import dagger.Module import dagger.Module
...@@ -14,14 +23,18 @@ interface DataComponent{ ...@@ -14,14 +23,18 @@ interface DataComponent{
} }
//@Module(includes = [DataModule::class,RetrofitModule::class,DbModule::class]) @Module(includes = [DataModule::class, RetrofitModule::class, DbModule::class,LocalStorage::class])
//abstract class ContractRepositoryModule @Inject constructor( abstract class ContractRepositoryModule {
// val authC:AuthContract
//){ @Binds
// abstract fun provideAuth(contract:AuthContractModule):AuthContract
@Binds
abstract fun provideFeedsContract(impl: FeedsContractModule): FeedsContract
//} @Binds
abstract fun provideDevProgressContract(impl: AlbumsContractModule): DevProgressContract
}
......
package com.biganto.visual.roompark.domain.use_case package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.data.data_provider.AlbumsContractModule import com.biganto.visual.roompark.domain.contract.DevProgressContract
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -8,7 +8,7 @@ import javax.inject.Inject ...@@ -8,7 +8,7 @@ import javax.inject.Inject
*/ */
class AlbumsUseCase @Inject constructor( class AlbumsUseCase @Inject constructor(
private val contract: AlbumsContractModule private val contract: DevProgressContract
){ ){
fun getProgressAlbums() = contract.getProgressCards() fun getProgressAlbums() = contract.getProgressCards()
......
...@@ -7,7 +7,6 @@ import com.biganto.visual.roompark.base.IBottomNavigation ...@@ -7,7 +7,6 @@ import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.di.dagger.CoreInjectHelper
import com.biganto.visual.roompark.presentation.screen.home.home_routing.HomeBottomNavigationController import com.biganto.visual.roompark.presentation.screen.home.home_routing.HomeBottomNavigationController
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
......
...@@ -78,6 +78,7 @@ class FeedsScreenController : ...@@ -78,6 +78,7 @@ class FeedsScreenController :
.map { feedsRecyclerView.layoutManager as LinearLayoutManager } .map { feedsRecyclerView.layoutManager as LinearLayoutManager }
.map { it.findLastCompletelyVisibleItemPosition() } .map { it.findLastCompletelyVisibleItemPosition() }
.doOnNext { Timber.d("Visible items $it of ${(feedsRecyclerView.adapter?.itemCount?:0) - 3}") } .doOnNext { Timber.d("Visible items $it of ${(feedsRecyclerView.adapter?.itemCount?:0) - 3}") }
.filter{feedsRecyclerView.adapter?.itemCount?:0 > 0}
.filter { it>(feedsRecyclerView.adapter?.itemCount?:0)-2 } .filter { it>(feedsRecyclerView.adapter?.itemCount?:0)-2 }
.map { feedsRecyclerView.adapter?.itemCount?:0 } .map { feedsRecyclerView.adapter?.itemCount?:0 }
.map { Pair(storedFeedsList[feedsTabs.selectedTabPosition],it)} .map { Pair(storedFeedsList[feedsTabs.selectedTabPosition],it)}
...@@ -213,8 +214,10 @@ class FeedsScreenController : ...@@ -213,8 +214,10 @@ class FeedsScreenController :
feedsTabs.addTab(tab) feedsTabs.addTab(tab)
} }
storedFeedsList = viewState.restore.feeds storedFeedsList = viewState.restore.feeds
} }
private fun getComponent() = DaggerFeedsScreenComponent.factory() private fun getComponent() = DaggerFeedsScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity) .create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this) .inject(this)
......
...@@ -2,32 +2,24 @@ package com.biganto.visual.roompark.presentation.screen.feeds ...@@ -2,32 +2,24 @@ package com.biganto.visual.roompark.presentation.screen.feeds
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.data.service.user_session.IUserSession import com.biganto.visual.roompark.data.service.user_session.IUserSession
import com.biganto.visual.roompark.data.service.user_session.UserSessionService import com.biganto.visual.roompark.data.service.user_session.UserSessionService
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AppModule
import com.biganto.visual.roompark.di.dagger.DataModule
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component
import dagger.Module import dagger.Module
import dagger.Subcomponent
@PerScreen @PerScreen
@Subcomponent( @Component(
modules = [FeedsScreenModule::class modules = [FeedsScreenModule::class]
, DataModule::class ,dependencies = [AppComponent::class]
, RetrofitModule::class
, AppModule::class
, DbModule::class]
// ,dependencies = [AppComponent::class]
) )
interface FeedsScreenComponent { interface FeedsScreenComponent {
@Subcomponent.Factory @Component.Factory
interface Factory{ interface Factory{
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
...@@ -35,8 +27,6 @@ interface FeedsScreenComponent { ...@@ -35,8 +27,6 @@ interface FeedsScreenComponent {
): FeedsScreenComponent ): FeedsScreenComponent
} }
val presenter: FeedsScreenPresenter
fun inject(controller: FeedsScreenController) fun inject(controller: FeedsScreenController)
} }
......
...@@ -82,7 +82,7 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -82,7 +82,7 @@ class FeedsScreenPresenter @Inject constructor(
.onErrorReturn (::parseError) .onErrorReturn (::parseError)
val state = restoreStateObservable val state = restoreStateObservable
// .mergeWith(fetchFeeds) .mergeWith(fetchFeeds)
.mergeWith(getFeedArticlesPreview) .mergeWith(getFeedArticlesPreview)
.mergeWith(fetchAlbums) .mergeWith(fetchAlbums)
.mergeWith(fetchCams) .mergeWith(fetchCams)
......
...@@ -2,27 +2,22 @@ package com.biganto.visual.roompark.presentation.screen.settings ...@@ -2,27 +2,22 @@ package com.biganto.visual.roompark.presentation.screen.settings
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AppModule
import com.biganto.visual.roompark.di.dagger.DataModule
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component
import dagger.Module import dagger.Module
import dagger.Subcomponent
@PerScreen @PerScreen
@Subcomponent( @Component(
modules = [SettingsScreenModule::class, DataModule::class modules = [SettingsScreenModule::class]
, RetrofitModule::class, AppModule::class, DbModule::class] ,dependencies = [AppComponent::class]
// ,dependencies = [AppComponent::class]
) )
interface SettingsScreenComponent { interface SettingsScreenComponent {
@Subcomponent.Factory @Component.Factory
interface Factory{ interface Factory{
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
...@@ -30,8 +25,6 @@ interface SettingsScreenComponent { ...@@ -30,8 +25,6 @@ interface SettingsScreenComponent {
): SettingsScreenComponent ): SettingsScreenComponent
} }
val presenter: SettingsScreenPresenter
fun inject(controller: SettingsScreenController) fun inject(controller: SettingsScreenController)
} }
......
...@@ -3,30 +3,25 @@ package com.biganto.visual.roompark.presentation.screen.splash ...@@ -3,30 +3,25 @@ package com.biganto.visual.roompark.presentation.screen.splash
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.IBottomNavigation import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AppModule
import com.biganto.visual.roompark.di.dagger.DataModule
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.presentation.screen.auth.AuthScreenModule
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component
import dagger.Module import dagger.Module
import dagger.Subcomponent
///** ///**
// * Created by Vladislav Bogdashkin on 30.09.2019. // * Created by Vladislav Bogdashkin on 30.09.2019.
// */ // */
@PerScreen @PerScreen
@Subcomponent( @Component(
modules = [AuthScreenModule::class,DataModule::class, RetrofitModule::class, AppModule::class, DbModule::class] modules = [SplashScreenModule::class]
// ,dependencies = [AppComponent::class] ,dependencies = [AppComponent::class]
) )
interface SplashScreenComponent { interface SplashScreenComponent {
@Subcomponent.Factory @Component.Factory
interface Factory{ interface Factory{
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
...@@ -34,8 +29,6 @@ interface SplashScreenComponent { ...@@ -34,8 +29,6 @@ interface SplashScreenComponent {
): SplashScreenComponent ): SplashScreenComponent
} }
val presenter: SplashScreenPresenter
fun inject(controller: SplashScreenController) fun inject(controller: SplashScreenController)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment