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

resolve singleton component dependencies

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