Commit 109c5265 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

try to resolve custom scope within singleton

parent bba046fb
......@@ -25,7 +25,7 @@ class AlbumsContractModule @Inject constructor(
override fun getProgressCards(): Observable<List<AlbumPreviewModel>> = fetchTopLevelAlbums()
override fun getProgressAlbumList(albumId: Int): Observable<List<AlbumPreviewModel>> =
fetchTopLevelAlbums()
fetchAlbums(albumId)
override fun getAlbumPhoto(photoId: Int): Observable<PhotoModel> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
......@@ -65,7 +65,7 @@ class AlbumsContractModule @Inject constructor(
).take(1).map { fromEntity(it,::fromEntity) }
private fun fetchAlbums(parentAlbumId:Int) =
private fun fetchAlbumsApi(parentAlbumId:Int) =
api.getAlbums(parentAlbumId)
.doOnNext { Timber.d("raw0 $it") }
.map{ fromRawList(it,::fromRaw) }
......@@ -83,5 +83,16 @@ class AlbumsContractModule @Inject constructor(
}
.subscribeOn(Schedulers.io())
private fun fetchAlbumsDb(parentAlbumId:Int) =
db.getChildAlbums(parentAlbumId)
.toList()
.toObservable()
.subscribeOn(Schedulers.io())
private fun fetchAlbums(parentId:Int): Observable<List<AlbumPreviewModel>> =
Observable.mergeDelayError(
arrayListOf(fetchAlbumsApi(parentId),fetchAlbumsDb(parentId))
).take(1).map { fromEntity(it,::fromEntity) }
}
......@@ -81,7 +81,7 @@ interface IRoomParkMobileApi{
//region GetFavorites
const val GET_ARTICLES_PAGE_METHOD="news.getArticlesList"
const val ARTICLES_PAGINATION_ALIAS_PARAM="feed_alias"
const val ARTICLES_PAGINATION_PAGE_SIZE_PARAM="pagesize "
const val ARTICLES_PAGINATION_PAGE_SIZE_PARAM="pagesize"
const val ARTICLES_PAGINATION_PAGE_PARAM="page"
//endregion
......
package com.biganto.visual.roompark.di.dagger
import com.biganto.visual.roompark.base.RoomParkApplication
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.requrey.DbModule
import dagger.BindsInstance
import dagger.Component
import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector
......@@ -11,6 +14,8 @@ import javax.inject.Singleton
/**
* Created by Vladislav Bogdashkin on 13.06.2018.
*/
......@@ -52,8 +57,12 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
@BindsInstance
fun retroApi(api: RetrofitRepository) : IRoomParkApi
}
// retorfitModule: RetrofitModule
// fun cache(): ICachedStore
// fun context(): Context
......
......@@ -9,6 +9,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.RequeryRepository
import dagger.Binds
import dagger.Component
import dagger.Module
import javax.inject.Singleton
@Component
interface DataComponent{
......@@ -16,6 +17,8 @@ interface DataComponent{
}
@Module
abstract class DataModule {
......@@ -30,6 +33,7 @@ abstract class DataModule {
// abstract fun provideRpRetrofit(retrofit:Retrofit) : Retrofit
//
@Singleton
@Binds
abstract fun provideRoomParkApi(api: RetrofitRepository) : IRoomParkApi
......
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import com.biganto.visual.roompark.domain.use_case.FeedUseCase
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.schedulers.Schedulers
import java.util.*
import javax.inject.Inject
......@@ -13,7 +12,8 @@ import javax.inject.Inject
*/
class FeedsInteractor @Inject constructor(
private val feedsUseCase:FeedUseCase
private val feedsUseCase: FeedUseCase,
private val albumsUseCase: AlbumsUseCase
) {
fun fetchTopFeeds(): Observable<FeedsHeaderModel> =
......@@ -33,9 +33,10 @@ class FeedsInteractor @Inject constructor(
fun fetchArticles(feedId: Int,pageSize:Int,startIndex:Int): Observable<ArticlesPreviewModel> =
feedsUseCase.fetchArticlesPage(feedId,pageSize,startIndex)
fun fetchAlbums(): Single<List<AlbumPreviewModel>> = Single.just(albumsPreviews)
fun fetchAlbums(): Observable<List<AlbumPreviewModel>> = albumsUseCase.getProgressAlbums()
fun fetchCams(): Single<WebCamListModel> = Single.just(camsList)
fun fetchCams(): Observable<WebCamListModel> = Observable.just(camsList)
companion object {
......
package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.data.data_provider.AlbumsContractModule
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
class AlbumsUseCase @Inject constructor(
private val contract: AlbumsContractModule
){
fun getProgressAlbums() = contract.getProgressCards()
fun getChildAlbum(parentAlbumId:Int) =
contract.getProgressAlbumList(parentAlbumId)
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ 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
......@@ -92,7 +93,9 @@ class AuthScreenController :
fun getComponent() = DaggerAuthScreenComponent
.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity)
.create(
RoomParkApplication.component
,activity as RoomParkMainActivity)
.inject(this)
override fun render(viewState: AuthScreenViewState) {
......
......@@ -11,29 +11,25 @@ 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.domain.contract.AuthContract
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import dagger.*
@PerScreen
@Component(
@Subcomponent(
modules = [
AuthScreenModule::class
,DataModule::class
,RetrofitModule::class
,AppModule::class
,DbModule::class
],
dependencies = [AppComponent::class])
])
interface AuthScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
appComponent: AppComponent,
@BindsInstance activity: RoomParkMainActivity
): AuthScreenComponent
}
......
......@@ -19,7 +19,6 @@ import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.button.MaterialButton
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.material.selections
import com.jakewharton.rxbinding3.recyclerview.scrollStateChanges
import com.jakewharton.rxbinding3.view.clicks
......@@ -45,8 +44,7 @@ class FeedsScreenController :
.map { it.position }
.map { storedFeedsList[it].feedId }
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { feedsBlockView.findViewById<MaterialButton>(R.id.to_feed_articles)
.text = "ВСЕ ${allFeedName(it)} →" }
.doOnNext { allFeedArticles.text = "ВСЕ ${allFeedName(it)} →" }
......@@ -70,7 +68,7 @@ class FeedsScreenController :
lateinit var feedsBlockView:ViewGroup
@BindView(R.id.to_feed_articles)
lateinit var allFeedArticles:MaterialTextView
lateinit var allFeedArticles: MaterialButton
......
......@@ -39,44 +39,50 @@ class FeedsScreenPresenter @Inject constructor(
override fun bindIntents() {
val fetchCams = interactor.fetchCams()
.map {
.map <FeedsScreenViewState>{
restoreModel.cams = it.items
FeedsScreenViewState.CamsList(it.items)
}
.onErrorReturn (::parseError)
val fetchAlbums = interactor.fetchAlbums()
.map {
.map <FeedsScreenViewState>{
restoreModel.albums = it
FeedsScreenViewState.AlbumsPages(it)
}
.onErrorReturn (::parseError)
val fetchFeeds = interactor.fetchTopFeeds()
.map {
.map <FeedsScreenViewState>{
restoreModel.feeds = it.feeds
FeedsScreenViewState.FeedsPages(it.feeds.toList())
}
.onErrorReturn (::parseError)
val getFeedArticlesPreview = intent(FeedsScreen::feedsTabSelected)
.flatMap { interactor.fetchArticles(it) }
.map {
.map<FeedsScreenViewState> {
restoreModel.articles = it.articles
FeedsScreenViewState.GetFeedArticlesPreview(it.articles.toList())
}
.onErrorReturn (::parseError)
val switchToAllArtiles = intent(FeedsScreen::onAllFeedArticles)
.map {
.map<FeedsScreenViewState> {
FeedsScreenViewState.ToArticlesScreen(it.feedId)
}
.onErrorReturn (::parseError)
val getNewArticlesPage = intent(FeedsScreen::requsetsNewArticles)
.flatMap { interactor.fetchArticles(it.first.feedId, FEED_PREVIEW_PAGE_SIZE,it.second) }
.map {
.map<FeedsScreenViewState> {
restoreModel.articles = it.articles
FeedsScreenViewState.ArticlesScrollPage(it.articles.toList())
}
.onErrorReturn (::parseError)
val state = restoreStateObservable
.mergeWith(fetchFeeds)
// .mergeWith(fetchFeeds)
.mergeWith(getFeedArticlesPreview)
.mergeWith(fetchAlbums)
.mergeWith(fetchCams)
......
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