Commit 60e9bf89 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

to flat now correctly seaking for estate

parent c68b4f84
...@@ -6,6 +6,7 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi ...@@ -6,6 +6,7 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
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.DealEntity import com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPresetEntity
import com.biganto.visual.roompark.data.repository.file.FileModule import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.data.repository.mapper.fromRaw import com.biganto.visual.roompark.data.repository.mapper.fromRaw
import com.biganto.visual.roompark.data.repository.mapper.fromRawList import com.biganto.visual.roompark.data.repository.mapper.fromRawList
...@@ -93,7 +94,7 @@ class EstateRepository @Inject constructor( ...@@ -93,7 +94,7 @@ class EstateRepository @Inject constructor(
} }
fun getPlanTypesApi(estateId: Int) = private fun getPlanTypesApi(estateId: Int): Observable<List<PlanPresetEntity>> =
api.getEstatePlanTypes(estateId) api.getEstatePlanTypes(estateId)
.doOnNext { Timber.d("raw0 $it") } .doOnNext { Timber.d("raw0 $it") }
.map { fromRawList(it, ::fromRaw) } .map { fromRawList(it, ::fromRaw) }
...@@ -223,7 +224,6 @@ class EstateRepository @Inject constructor( ...@@ -223,7 +224,6 @@ class EstateRepository @Inject constructor(
else -> throw CustomApiException.NotAuthorizedException() else -> throw CustomApiException.NotAuthorizedException()
} }
} }
.doOnNext { Timber.d("deals db: $it") }
.map { it.deals?.map {deal -> deal as DealEntity } } .map { it.deals?.map {deal -> deal as DealEntity } }
...@@ -234,10 +234,31 @@ class EstateRepository @Inject constructor( ...@@ -234,10 +234,31 @@ class EstateRepository @Inject constructor(
) )
) )
.doOnNext { Timber.d("step 3: $it") }
.map { fromEntity(it, ::fromEntity) } .map { fromEntity(it, ::fromEntity) }
.doOnError(Timber::e) .doOnError(Timber::e)
.subscribeOn (Schedulers.io()) .subscribeOn (Schedulers.io())
} }
private fun fetchEstateApi(building: Int,number:Int)=
api.getEstate(building,number)
.doOnNext { Timber.d("raw0 $it") }
.map (::fromRaw)
.doOnNext(db::upsertEstate)
.subscribeOn(Schedulers.io())
private fun fetchEstateDb(building: Int,number:Int) =
db.fetchEstateByNumber(building,number.toString())
.observable()
.subscribeOn(Schedulers.io())
override fun fetchEstate(building: Int,number:Int): Observable<EstateModel> =
Observable.mergeDelayError(
arrayListOf(fetchEstateApi(building,number),
fetchEstateDb(building,number)
)
).map (::fromEntity)
} }
...@@ -10,10 +10,6 @@ import retrofit2.http.* ...@@ -10,10 +10,6 @@ import retrofit2.http.*
* Created by Vladislav Bogdashkin on 13.06.2018. * Created by Vladislav Bogdashkin on 13.06.2018.
*/ */
interface IRoomParkMobileApi{ interface IRoomParkMobileApi{
companion object{ companion object{
...@@ -117,15 +113,15 @@ interface IRoomParkMobileApi{ ...@@ -117,15 +113,15 @@ interface IRoomParkMobileApi{
//region Get MultitourId //region Get MultitourId
const val GET_MULTITOUR_ID="estates.getMultiTour" const val GET_MULTITOUR_ID="estates.getMultiTour"
const val MULTITOUR_BUILDING_NUMBER_PARAM="building " const val MULTITOUR_BUILDING_NUMBER_PARAM="building"
const val MULTITOUR_FLAT_NUMBER_PARAM="number " const val MULTITOUR_FLAT_NUMBER_PARAM="number"
//endregion //endregion
//region Get Estate //region Get Estate
const val GET_ESTATE_ID="estates.getEstate" const val GET_ESTATE_ID="estates.getEstate"
const val ESTATE_BUILDING_NUMBER_PARAM="building " const val ESTATE_BUILDING_NUMBER_PARAM="building"
const val ESTATE_FLAT_NUMBER_PARAM="number " const val ESTATE_FLAT_NUMBER_PARAM="number"
//endregion //endregion
//region Get Web Cams //region Get Web Cams
...@@ -145,7 +141,6 @@ interface IRoomParkMobileApi{ ...@@ -145,7 +141,6 @@ interface IRoomParkMobileApi{
@Field(PASSWORD_AUTH_PARAM) pwd: String @Field(PASSWORD_AUTH_PARAM) pwd: String
): Observable<Response<AuthRaw>> ): Observable<Response<AuthRaw>>
@POST("$API_URL${SUBSCRIBE_METHOD}OD$DELIMITER") @POST("$API_URL${SUBSCRIBE_METHOD}OD$DELIMITER")
fun subscribe( fun subscribe(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -166,7 +161,6 @@ interface IRoomParkMobileApi{ ...@@ -166,7 +161,6 @@ interface IRoomParkMobileApi{
@Query(TOPIC_SUBSCRIBTION_PARAM) topic: String @Query(TOPIC_SUBSCRIBTION_PARAM) topic: String
): Observable<Response<StatusResponse>> ): Observable<Response<StatusResponse>>
@GET("$API_URL$DEALS_METHOD$DELIMITER") @GET("$API_URL$DEALS_METHOD$DELIMITER")
fun getDeals( fun getDeals(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -175,7 +169,6 @@ interface IRoomParkMobileApi{ ...@@ -175,7 +169,6 @@ interface IRoomParkMobileApi{
@Query(AUTH_TOKEN) token: String @Query(AUTH_TOKEN) token: String
): Observable<Response<List<DealRaw>>> ): Observable<Response<List<DealRaw>>>
@GET("$API_URL$FAVORITES_METHOD$DELIMITER") @GET("$API_URL$FAVORITES_METHOD$DELIMITER")
fun getFavorites( fun getFavorites(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -191,7 +184,6 @@ interface IRoomParkMobileApi{ ...@@ -191,7 +184,6 @@ interface IRoomParkMobileApi{
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION @Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION
): Observable<Response<List<FeedRaw>>> ): Observable<Response<List<FeedRaw>>>
@GET("$API_URL$GET_WEB_CAMS_METHOD$DELIMITER") @GET("$API_URL$GET_WEB_CAMS_METHOD$DELIMITER")
fun getWebCams( fun getWebCams(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -199,7 +191,6 @@ interface IRoomParkMobileApi{ ...@@ -199,7 +191,6 @@ interface IRoomParkMobileApi{
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION @Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION
): Observable<Response<List<WebCamRaw>>> ): Observable<Response<List<WebCamRaw>>>
@GET("$API_URL$GET_ARTICLES_PAGE_METHOD$DELIMITER") @GET("$API_URL$GET_ARTICLES_PAGE_METHOD$DELIMITER")
fun getArticlesPage( fun getArticlesPage(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -210,7 +201,6 @@ interface IRoomParkMobileApi{ ...@@ -210,7 +201,6 @@ interface IRoomParkMobileApi{
@Query(ARTICLES_PAGINATION_PAGE_PARAM) page: Int @Query(ARTICLES_PAGINATION_PAGE_PARAM) page: Int
): Observable<Response<ArticlesListPaginationRaw>> ): Observable<Response<ArticlesListPaginationRaw>>
@GET("$API_URL$GET_ARTICLE_METHOD$DELIMITER") @GET("$API_URL$GET_ARTICLE_METHOD$DELIMITER")
fun getArticle( fun getArticle(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -219,8 +209,6 @@ interface IRoomParkMobileApi{ ...@@ -219,8 +209,6 @@ interface IRoomParkMobileApi{
@Query(ARTICLE_ID_PARAM) id: Int @Query(ARTICLE_ID_PARAM) id: Int
): Observable<Response<ArticleRaw>> ): Observable<Response<ArticleRaw>>
@GET("$API_URL$ALBUMS_METHOD$DELIMITER") @GET("$API_URL$ALBUMS_METHOD$DELIMITER")
fun getAlbums( fun getAlbums(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -229,7 +217,6 @@ interface IRoomParkMobileApi{ ...@@ -229,7 +217,6 @@ interface IRoomParkMobileApi{
@Query(PARENT_ALBUMD_ID_PARAM) id: Int? @Query(PARENT_ALBUMD_ID_PARAM) id: Int?
): Observable<Response<List<ImageAlbumRaw>>> ): Observable<Response<List<ImageAlbumRaw>>>
@GET("$API_URL$PHOTOS_METHOD$DELIMITER") @GET("$API_URL$PHOTOS_METHOD$DELIMITER")
fun getPhotos( fun getPhotos(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -238,7 +225,6 @@ interface IRoomParkMobileApi{ ...@@ -238,7 +225,6 @@ interface IRoomParkMobileApi{
@Query(PHOTOS_ALBUMD_ID_PARAM) id: Int @Query(PHOTOS_ALBUMD_ID_PARAM) id: Int
): Observable<Response<List<GalleryImageRaw>>> ): Observable<Response<List<GalleryImageRaw>>>
@GET("$API_URL$GET_PLAN_TYPES_METHOD$DELIMITER") @GET("$API_URL$GET_PLAN_TYPES_METHOD$DELIMITER")
fun getPlanTypes( fun getPlanTypes(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -247,7 +233,6 @@ interface IRoomParkMobileApi{ ...@@ -247,7 +233,6 @@ interface IRoomParkMobileApi{
@Query(PLAN_TYPES_ESTATE_ID_PARAM) estateId: Int @Query(PLAN_TYPES_ESTATE_ID_PARAM) estateId: Int
): Observable<Response<List<PlanTypeRaw>>> ): Observable<Response<List<PlanTypeRaw>>>
@GET("$API_URL$GET_DIRECT_PLAN_METHOD$DELIMITER") @GET("$API_URL$GET_DIRECT_PLAN_METHOD$DELIMITER")
fun getPlan( fun getPlan(
@Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE, @Query(CLIENT_TYPE_PARAM) clientType: String = DEFAULT_CLIENT_TYPE,
...@@ -261,7 +246,6 @@ interface IRoomParkMobileApi{ ...@@ -261,7 +246,6 @@ interface IRoomParkMobileApi{
@Query(DIRECT_PLAN_ELECTRIC_PARAM) electric:Int @Query(DIRECT_PLAN_ELECTRIC_PARAM) electric:Int
): Observable<Response<String>> ): Observable<Response<String>>
@Deprecated("change to estates.getEstate method as more common") @Deprecated("change to estates.getEstate method as more common")
@GET("$API_URL$GET_MULTITOUR_ID$DELIMITER") @GET("$API_URL$GET_MULTITOUR_ID$DELIMITER")
fun getMultiTourId( fun getMultiTourId(
...@@ -280,6 +264,4 @@ interface IRoomParkMobileApi{ ...@@ -280,6 +264,4 @@ interface IRoomParkMobileApi{
@Query(ESTATE_BUILDING_NUMBER_PARAM) building:Int, @Query(ESTATE_BUILDING_NUMBER_PARAM) building:Int,
@Query(ESTATE_FLAT_NUMBER_PARAM) flatNumber:Int @Query(ESTATE_FLAT_NUMBER_PARAM) flatNumber:Int
): Observable<Response<EstateRaw>> ): Observable<Response<EstateRaw>>
} }
\ No newline at end of file
...@@ -29,4 +29,6 @@ interface IDb { ...@@ -29,4 +29,6 @@ interface IDb {
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> fun getEstate(estateId: Int): Observable<EstateEntity>
fun upsertEstate(entity: EstateEntity)
fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity>
} }
\ No newline at end of file
...@@ -58,10 +58,18 @@ class RequeryRepository @Inject constructor( ...@@ -58,10 +58,18 @@ class RequeryRepository @Inject constructor(
override fun <T : List<Persistable>> blockingUpsert(entity: T) = override fun <T : List<Persistable>> blockingUpsert(entity: T) =
store.upsert(entity).toObservable().blockingSubscribe() store.upsert(entity).toObservable().blockingSubscribe()
override fun upsertEstate(entity:EstateEntity) =
store.upsert(entity).toObservable().blockingSubscribe()
override fun fetchFeeds(): Observable<FeedEntity> = override fun fetchFeeds(): Observable<FeedEntity> =
fetchAll<FeedEntity>().get().observable() fetchAll<FeedEntity>().get().observable()
override fun fetchEstateByNumber(building:Int,number:String): ReactiveResult<EstateEntity> =
store.select(EstateEntity::class)
.where(EstateEntity.NUMBER.eq(number))
.and(EstateEntity.INFO_BUILDING.eq(building))
.get()
override fun getFeed(feedAlias: String): ReactiveResult<FeedEntity> = override fun getFeed(feedAlias: String): ReactiveResult<FeedEntity> =
fetchAll<FeedEntity>().where(FeedEntity.ALIAS.eq(feedAlias)) fetchAll<FeedEntity>().where(FeedEntity.ALIAS.eq(feedAlias))
.get() .get()
......
...@@ -26,4 +26,5 @@ interface DealContract{ ...@@ -26,4 +26,5 @@ interface DealContract{
fun getDeals(): Observable<List<DealModel>> fun getDeals(): Observable<List<DealModel>>
fun fetchEstate(building: Int, number: Int): 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.model.TourModel import com.biganto.visual.roompark.domain.use_case.EstateUseCase
import com.biganto.visual.roompark.domain.model.TourRequestModel
import com.biganto.visual.roompark.domain.model.TourResponse
import io.reactivex.Observable import io.reactivex.Observable
import javax.inject.Inject import javax.inject.Inject
...@@ -11,18 +9,11 @@ import javax.inject.Inject ...@@ -11,18 +9,11 @@ import javax.inject.Inject
*/ */
class FindFlatInteractor @Inject constructor( class FindFlatInteractor @Inject constructor(
val useCase:EstateUseCase
){ ){
fun getFlat(requaest: TourRequestModel): Observable<TourResponse> = fun getFlat(building:Int,flat:Int): Observable<Int>
Observable.just(tourResponseMock) = useCase.fetchEstate(building,flat)
.map { it.id }
companion object{
val tourResponseMock = TourResponse(arrayListOf(
TourModel("125","Tour s otdelkoj",null),
TourModel("126","Tour bez otdelki",null)
)
)
}
} }
\ No newline at end of file
...@@ -5,6 +5,6 @@ package com.biganto.visual.roompark.domain.model ...@@ -5,6 +5,6 @@ package com.biganto.visual.roompark.domain.model
*/ */
data class TourRequestModel(val building:Int, val flat:String) data class TourRequestModel(val building:Int, val flat:Int)
data class TourResponse(val response:List<TourModel>) data class TourResponse(val response:List<TourModel>)
data class TourModel(val tourId:String, val title:String, val preview:String?) data class TourModel(val tourId:String, val title:Int, val preview:String?)
...@@ -15,6 +15,9 @@ class EstateUseCase @Inject constructor( ...@@ -15,6 +15,9 @@ class EstateUseCase @Inject constructor(
fun getEstate(estateId: Int) = contract.getEstate(estateId) fun getEstate(estateId: Int) = contract.getEstate(estateId)
fun fetchEstate(building:Int, number:Int) =
contract.fetchEstate(building, number)
fun getEstatePlanPresets(estateId: Int) = fun getEstatePlanPresets(estateId: Int) =
contract.getPlanTypes(estateId) contract.getPlanTypes(estateId)
......
...@@ -12,6 +12,7 @@ import com.biganto.visual.roompark.presentation.screen.deal.DealScreenController ...@@ -12,6 +12,7 @@ import com.biganto.visual.roompark.presentation.screen.deal.DealScreenController
import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -71,8 +72,8 @@ class DealsScreenController : ...@@ -71,8 +72,8 @@ class DealsScreenController :
.subscribe { .subscribe {
Timber.d("got card clicked $it") Timber.d("got card clicked $it")
router.pushController(RouterTransaction.with(DealScreenController(it.id)) router.pushController(RouterTransaction.with(DealScreenController(it.id))
// .pushChangeHandler(FadeChangeHandler()) .pushChangeHandler(FadeChangeHandler())
// .popChangeHandler(FadeChangeHandler()) .popChangeHandler(FadeChangeHandler())
) )
} }
) )
......
package com.biganto.visual.roompark.presentation.screen.to_flat package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBaseContract import com.biganto.visual.roompark.conductor.BigantoBaseContract
import com.biganto.visual.roompark.domain.model.TourRequestModel
import io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -9,7 +8,7 @@ import io.reactivex.Observable ...@@ -9,7 +8,7 @@ import io.reactivex.Observable
*/ */
interface FindFlatScreen : BigantoBaseContract<FindFlatScreenViewState> { interface FindFlatScreen : BigantoBaseContract<FindFlatScreenViewState> {
fun getFlat() : Observable<TourRequestModel> fun getFlat() : Observable<FlatRequestModel>
fun startTour() : Observable<String>
} }
data class FlatRequestModel(val number:Int,val building:Int)
\ No newline at end of file
...@@ -9,13 +9,16 @@ import com.biganto.visual.roompark.R ...@@ -9,13 +9,16 @@ import com.biganto.visual.roompark.R
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.domain.model.TourRequestModel import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.EstateTabModel import com.biganto.visual.roompark.presentation.screen.feeds.EstateTabModel
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import com.jakewharton.rxbinding3.view.keys import com.jakewharton.rxbinding3.view.keys
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -30,17 +33,17 @@ class FindFlatScreenController : ...@@ -30,17 +33,17 @@ class FindFlatScreenController :
, FindFlatScreen { , FindFlatScreen {
override fun getFlat(): Observable<TourRequestModel> = override fun getFlat(): Observable<FlatRequestModel> =
flatNumberEditor.keys { it.keyCode == KeyEvent.KEYCODE_ENTER } flatNumberEditor.keys { it.keyCode == KeyEvent.KEYCODE_ENTER }
.doOnNext { flatNumberEditor.hideKeyboard() } .doOnNext { flatNumberEditor.hideKeyboard() }
.map { .map {
TourRequestModel( FlatRequestModel(
estateTabs[flatTabs.selectedTabPosition].building estateTabs[flatTabs.selectedTabPosition].building
, flatNumberInput.editText?.text.toString() , flatNumberInput.editText?.text.toString().toInt()
) )
} }
.observeOn(AndroidSchedulers.mainThread())
override fun startTour(): Observable<String> = Observable.just("1")
override fun injectDependencies() { override fun injectDependencies() {
getComponent() getComponent()
...@@ -101,8 +104,8 @@ class FindFlatScreenController : ...@@ -101,8 +104,8 @@ class FindFlatScreenController :
Timber.d("Render state $viewState") Timber.d("Render state $viewState")
when(viewState){ when(viewState){
is FindFlatScreenViewState.Idle -> render(viewState) is FindFlatScreenViewState.Idle -> render(viewState)
is FindFlatScreenViewState.StartTour -> render(viewState)
is FindFlatScreenViewState.SomeError -> render(viewState) is FindFlatScreenViewState.SomeError -> render(viewState)
is FindFlatScreenViewState.FlatFounded -> render(viewState)
} }
} }
...@@ -110,7 +113,14 @@ class FindFlatScreenController : ...@@ -110,7 +113,14 @@ class FindFlatScreenController :
showError(viewState.exception) showError(viewState.exception)
private fun render(viewState: FindFlatScreenViewState.Idle){ private fun render(viewState: FindFlatScreenViewState.Idle){
}
private fun render(viewState: FindFlatScreenViewState.FlatFounded){
router.pushController(
RouterTransaction.with(EstateScreenController(viewState.esateId))
.pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler())
)
} }
private fun getComponent() = DaggerFindFlatScreenComponent.factory() private fun getComponent() = DaggerFindFlatScreenComponent.factory()
......
...@@ -25,26 +25,18 @@ class FindFlatScreenPresenter @Inject constructor( ...@@ -25,26 +25,18 @@ class FindFlatScreenPresenter @Inject constructor(
override fun bindIntents() { override fun bindIntents() {
val startTourIntent = intent(FindFlatScreen::startTour)
.filter { false }
.map { FindFlatScreenViewState.StartTour(it) }
val getFlatIntent = intent(FindFlatScreen::getFlat) val getFlatIntent = intent(FindFlatScreen::getFlat)
.doOnNext{Timber.d(" flat is $it")} .doOnNext{Timber.d(" flat is $it")}
.flatMap { request -> .flatMap { request ->
interactor.getFlat(request) interactor.getFlat(request.building,request.number)
.map { .map<FindFlatScreenViewState> {FindFlatScreenViewState.FlatFounded(it)}
if (it.response.isNullOrEmpty()) FindFlatScreenViewState.FlatNotFound() .onErrorReturn (::parseError)
else FindFlatScreenViewState.TourFounded(it.response)
}
.onErrorReturn { Timber.e(it);FindFlatScreenViewState.RequstFlatProgress() }
} }
.startWith(Observable.just(FindFlatScreenViewState.RequstFlatProgress())) .startWith(Observable.just(FindFlatScreenViewState.RequstFlatProgress()))
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(getFlatIntent) .mergeWith(getFlatIntent)
.mergeWith(startTourIntent)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
package com.biganto.visual.roompark.presentation.screen.to_flat package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
...@@ -12,8 +11,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString ...@@ -12,8 +11,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
sealed class FindFlatScreenViewState : BigantoBaseViewState() { sealed class FindFlatScreenViewState : BigantoBaseViewState() {
class Idle : FindFlatScreenViewState() class Idle : FindFlatScreenViewState()
class RequstFlatProgress : FindFlatScreenViewState() class RequstFlatProgress : FindFlatScreenViewState()
class TourFounded(val items:List<TourModel>) : FindFlatScreenViewState() class FlatFounded(val esateId:Int) : FindFlatScreenViewState()
class StartTour(val tourId:String) : FindFlatScreenViewState() class FlatNotFound : FindFlatScreenViewState()
class FlatNotFound() : FindFlatScreenViewState()
class SomeError(val exception: ExceptionString) : FindFlatScreenViewState() class SomeError(val exception: ExceptionString) : FindFlatScreenViewState()
} }
\ No newline at end of file
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