Commit cf0ad03d authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

estate usecase

parent a3679ba1
...@@ -76,4 +76,11 @@ class EstateRepository @Inject constructor( ...@@ -76,4 +76,11 @@ class EstateRepository @Inject constructor(
} }
private fun fetchEstateDb(id:Int) = db.getEstate(id)
override fun getEstate(estateId:Int) : Observable<EstateModel>{
return fetchEstateDb(estateId).map (::fromEntity)
}
} }
...@@ -28,4 +28,5 @@ interface IDb { ...@@ -28,4 +28,5 @@ interface IDb {
fun getAlbum(albumId: Int): Observable<ImageAlbumEntity> fun getAlbum(albumId: Int): Observable<ImageAlbumEntity>
fun getUserFavorites(uuid: Int): Observable<EstateEntity> fun getUserFavorites(uuid: Int): Observable<EstateEntity>
fun fetchAllUsers(): Observable<List<UserEntity>> fun fetchAllUsers(): Observable<List<UserEntity>>
fun getEstate(estateId: Int): Observable<EstateEntity>
} }
\ No newline at end of file
...@@ -95,6 +95,11 @@ class RequeryRepository @Inject constructor( ...@@ -95,6 +95,11 @@ class RequeryRepository @Inject constructor(
.where(ImageAlbumEntity.ID.eq(albumId)) .where(ImageAlbumEntity.ID.eq(albumId))
.get().observable() .get().observable()
override fun getEstate(estateId: Int): Observable<EstateEntity> =
store.select(EstateEntity::class)
.where(EstateEntity.ID.eq(estateId))
.get().observable()
override fun getPhotos(albumId: Int): Observable<GalleryPhotoEntity> = override fun getPhotos(albumId: Int): Observable<GalleryPhotoEntity> =
store.select(GalleryPhotoEntity::class) store.select(GalleryPhotoEntity::class)
.where(GalleryPhotoEntity.ALBUM_ID.eq(albumId)) .where(GalleryPhotoEntity.ALBUM_ID.eq(albumId))
...@@ -141,5 +146,6 @@ class RequeryRepository @Inject constructor( ...@@ -141,5 +146,6 @@ class RequeryRepository @Inject constructor(
override fun getUserFavorites(uuid: Int): Observable<EstateEntity> = override fun getUserFavorites(uuid: Int): Observable<EstateEntity> =
store.select(EstateEntity::class) store.select(EstateEntity::class)
.where(EstateEntity.USER_ID.eq(uuid)) .where(EstateEntity.USER_ID.eq(uuid))
.and(EstateEntity.FAVORITE.eq(true))
.get().observable() .get().observable()
} }
\ No newline at end of file
...@@ -11,4 +11,5 @@ import io.reactivex.rxjava3.core.Observable ...@@ -11,4 +11,5 @@ import io.reactivex.rxjava3.core.Observable
interface DealContract{ interface DealContract{
fun getFavorites() : io.reactivex.Observable<List<EstateModel>> fun getFavorites() : io.reactivex.Observable<List<EstateModel>>
fun getEstate(estateId: Int): io.reactivex.Observable<EstateModel>
} }
\ No newline at end of file
package com.biganto.visual.roompark.domain.interactor package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.use_case.EstateUseCase
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -7,8 +8,9 @@ import javax.inject.Inject ...@@ -7,8 +8,9 @@ import javax.inject.Inject
*/ */
class EstateInteractor @Inject constructor( class EstateInteractor @Inject constructor(
private val useCase: EstateUseCase
){ ){
fun getEstate(estateId:Int) = null fun getEstate(estateId:Int) = useCase.getEstate(estateId)
} }
\ No newline at end of file
...@@ -13,4 +13,6 @@ class EstateUseCase @Inject constructor( ...@@ -13,4 +13,6 @@ class EstateUseCase @Inject constructor(
fun fetchFavorites() = contract.getFavorites() fun fetchFavorites() = contract.getFavorites()
fun getEstate(estateId:Int) =contract.getEstate(estateId)
} }
\ No newline at end of file
...@@ -16,6 +16,9 @@ import javax.inject.Inject ...@@ -16,6 +16,9 @@ import javax.inject.Inject
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
*/ */
const val SELECTED_ESTATE_ID_KEY = "SELECTED_ESTATE_INDEX"
class EstateScreenController : class EstateScreenController :
BigantoBaseController<EstateScreenViewState BigantoBaseController<EstateScreenViewState
, EstateScreen , EstateScreen
......
...@@ -8,6 +8,7 @@ import dagger.Binds ...@@ -8,6 +8,7 @@ import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.Module import dagger.Module
import javax.inject.Named
@PerScreen @PerScreen
...@@ -21,6 +22,7 @@ interface EstateScreenComponent { ...@@ -21,6 +22,7 @@ interface EstateScreenComponent {
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity ,@BindsInstance activity: RoomParkMainActivity
,@BindsInstance @Named(SELECTED_ESTATE_ID_KEY) selectedEstateId:Int
): EstateScreenComponent ): EstateScreenComponent
} }
......
...@@ -7,6 +7,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers ...@@ -7,6 +7,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Named
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -14,7 +15,8 @@ import javax.inject.Inject ...@@ -14,7 +15,8 @@ import javax.inject.Inject
class EstateScreenPresenter @Inject constructor( class EstateScreenPresenter @Inject constructor(
private val interactor: EstateInteractor private val interactor: EstateInteractor,
@Named(SELECTED_ESTATE_ID_KEY) private val estateId:Int
) )
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() { : BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
...@@ -23,7 +25,8 @@ class EstateScreenPresenter @Inject constructor( ...@@ -23,7 +25,8 @@ class EstateScreenPresenter @Inject constructor(
override fun bindIntents() { override fun bindIntents() {
val prefetchCards = interactor.getEstate(1) val prefetchCards = interactor.getEstate(estateId)
.map { EstateScreenViewState.LoadEstate(it) }
//.map { EstateScreenViewState.FavoriteEstatesLoaded(it) } //.map { EstateScreenViewState.FavoriteEstatesLoaded(it) }
val state = restoreStateObservable val state = restoreStateObservable
......
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