Commit 99cecf5f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

estate resotre model

parent 817a65ce
...@@ -80,7 +80,7 @@ class ChooseTourDialogController : Controller { ...@@ -80,7 +80,7 @@ class ChooseTourDialogController : Controller {
.subscribe(::onTourClicked) .subscribe(::onTourClicked)
) )
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() } // view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view.setOnClickListener { handleBack() } view.setOnClickListener { handleBack() }
return view return view
......
package com.biganto.visual.roompark.presentation.screen.estate package com.biganto.visual.roompark.presentation.screen.estate
import android.annotation.SuppressLint
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
...@@ -262,6 +263,7 @@ class EstateScreenController : ...@@ -262,6 +263,7 @@ class EstateScreenController :
is EstateScreenViewState.SomeError -> render(viewState) is EstateScreenViewState.SomeError -> render(viewState)
is EstateScreenViewState.ShowEstateInfo -> render(viewState) is EstateScreenViewState.ShowEstateInfo -> render(viewState)
is EstateScreenViewState.ToursLoaded -> render(viewState) is EstateScreenViewState.ToursLoaded -> render(viewState)
is EstateScreenViewState.RestoreView -> render(viewState)
} }
} }
...@@ -277,40 +279,12 @@ class EstateScreenController : ...@@ -277,40 +279,12 @@ class EstateScreenController :
private var estateModel : EstateModel? = null private var estateModel : EstateModel? = null
private fun render(viewState: EstateScreenViewState.LoadEstate) { private fun render(viewState: EstateScreenViewState.LoadEstate) {
estateModel = viewState.estate setEstateInfo(viewState.estate)
toolBar.setToolbar(
null, StatusToolbarModel(StatusState.AVAILABLE,null, null)
)
flatTitle.text = resources?.getString(viewState.estate.type.typeShortString()
,viewState.estate.number)
siteLink.setGone(viewState.estate.url == null)
viewState.estate.url?.let {url ->
siteLink.setOnClickListener{
activity?.startUrl(url)
}
} }
startTour.setGone(viewState.estate.multitourId == null)
startTourDivider.setGone(viewState.estate.multitourId == null)
viewState.estate.multitourPreview?.let {
Glide.with(tourScreen)
.load(it)
.into(tourScreen)
}
when(viewState.estate.type){ private fun render(viewState: EstateScreenViewState.RestoreView) {
FlatType.FLAT -> { setEstateInfo(viewState.restore.estate)
flatTypeView.setGone(false)
infoTabDivicder.setGone(false)
explicationTab.setGone(false)
}
else -> {
flatTypeView.setGone(true)
infoTabDivicder.setGone(true)
explicationTab.setGone(true)
}
}
} }
...@@ -395,6 +369,7 @@ class EstateScreenController : ...@@ -395,6 +369,7 @@ class EstateScreenController :
} }
@SuppressLint("SetJavaScriptEnabled")
private fun render(viewState: EstateScreenViewState.LoadPlan) { private fun render(viewState: EstateScreenViewState.LoadPlan) {
planWebView.settings.javaScriptEnabled = true planWebView.settings.javaScriptEnabled = true
planWebView.clearCache(true) planWebView.clearCache(true)
...@@ -402,11 +377,51 @@ class EstateScreenController : ...@@ -402,11 +377,51 @@ class EstateScreenController :
planWebView.loadUrl(uri) planWebView.loadUrl(uri)
} }
private fun setEstateInfo(estateModel: EstateModel?){
toolBar.setToolbar(
null, StatusToolbarModel(StatusState.AVAILABLE,null, null)
)
estateModel?.let {estate ->
flatTitle.text = resources?.getString(estate.type.typeShortString()
,estate.number)
}
siteLink.setGone(estateModel?.url == null)
estateModel?.url?.let {url ->
siteLink.setOnClickListener{
activity?.startUrl(url)
}
}
startTour.setGone(estateModel?.multitourId == null)
startTourDivider.setGone(estateModel?.multitourId == null)
estateModel?.multitourPreview?.let {
Glide.with(tourScreen)
.load(it)
.into(tourScreen)
}
when(estateModel?.type){
FlatType.FLAT -> {
flatTypeView.setGone(false)
infoTabDivicder.setGone(false)
explicationTab.setGone(false)
}
else -> {
flatTypeView.setGone(true)
infoTabDivicder.setGone(true)
explicationTab.setGone(true)
}
}
}
private fun getComponent() = DaggerEstateScreenComponent.factory() private fun getComponent() = DaggerEstateScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity .create(RoomParkApplication.component,activity as RoomParkMainActivity
,args.getInt(SELECTED_ESTATE_ID_KEY)) ,args.getInt(SELECTED_ESTATE_ID_KEY))
.inject(this) .inject(this)
override fun getLayoutId(): Int = R.layout.flat_full_card_screen override fun getLayoutId(): Int = R.layout.flat_full_card_screen
......
...@@ -30,11 +30,6 @@ class EstateScreenPresenter @Inject constructor( ...@@ -30,11 +30,6 @@ class EstateScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() { : BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
private var planList: List<PlanPresetModel>? = null
private var estate: EstateModel? = null
private var showType: InfoShowType = InfoShowType.COMMON_INFO
override fun defaultErrorViewStateHandler() = override fun defaultErrorViewStateHandler() =
{ e: ExceptionString -> EstateScreenViewState.SomeError(e) } { e: ExceptionString -> EstateScreenViewState.SomeError(e) }
...@@ -43,18 +38,26 @@ class EstateScreenPresenter @Inject constructor( ...@@ -43,18 +38,26 @@ class EstateScreenPresenter @Inject constructor(
interactor.getPlan(plan) interactor.getPlan(plan)
.map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) } .map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) }
private var restoreModel = RestoreModel(null,null)
override fun detachView() {
super.detachView()
restoreStateObservable.accept(EstateScreenViewState.RestoreView(restoreModel))
}
override fun bindIntents() { override fun bindIntents() {
val prefetchCards = interactor.getEstate(estateId) val prefetchCards = interactor.getEstate(estateId)
.doOnNext { estate = it.copy() } .doOnNext { restoreModel.estate = it.copy() }
.map { EstateScreenViewState.LoadEstate(it) } .map { EstateScreenViewState.LoadEstate(it) }
val fetchPlans = interactor.getPlanTypes(estateId) val fetchPlans = interactor.getPlanTypes(estateId)
.doOnNext { planList = it.toList() } .doOnNext {restoreModel.planList = it.toList() }
.map { EstateScreenViewState.LoadPlanTypes(it) } .map { EstateScreenViewState.LoadPlanTypes(it) }
val fetchPlan = intent(EstateScreen::planTypesTabSelected) val fetchPlan = intent(EstateScreen::planTypesTabSelected)
.map { planList?.get(it) } .map { restoreModel.planList?.get(it) }
.flatMap { planPreset -> .flatMap { planPreset ->
interactor.getPlan(planPreset) interactor.getPlan(planPreset)
.map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) } .map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) }
...@@ -67,9 +70,9 @@ class EstateScreenPresenter @Inject constructor( ...@@ -67,9 +70,9 @@ class EstateScreenPresenter @Inject constructor(
Observable.just<EstateScreenViewState>( Observable.just<EstateScreenViewState>(
EstateScreenViewState.ShowEstateInfo( EstateScreenViewState.ShowEstateInfo(
showType restoreModel.showType
, if (showType == InfoShowType.COMMON_INFO) , if (restoreModel.showType == InfoShowType.COMMON_INFO)
mapCommonInfo(estate?.commonInfo) mapCommonInfo(restoreModel.estate?.commonInfo)
else mapCommonInfo(planPreset.explication) else mapCommonInfo(planPreset.explication)
) )
) )
...@@ -78,48 +81,48 @@ class EstateScreenPresenter @Inject constructor( ...@@ -78,48 +81,48 @@ class EstateScreenPresenter @Inject constructor(
val switchSizes = intent(EstateScreen::switchSizes) val switchSizes = intent(EstateScreen::switchSizes)
.map { pair -> .map { pair ->
val plan = planList?.first { it.planId == pair.first } val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Sizes>(pair.second) plan?.switchFeature<FeatureModel.Sizes>(pair.second)
plan plan
}.flatMap(::getPlan) }.flatMap(::getPlan)
val switchFurn = intent(EstateScreen::switchFurniture) val switchFurn = intent(EstateScreen::switchFurniture)
.map { pair -> .map { pair ->
val plan = planList?.first { it.planId == pair.first } val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Furniture>(pair.second) plan?.switchFeature<FeatureModel.Furniture>(pair.second)
plan plan
}.flatMap(::getPlan) }.flatMap(::getPlan)
val switchWalls = intent(EstateScreen::switchWalls) val switchWalls = intent(EstateScreen::switchWalls)
.map { pair -> .map { pair ->
val plan = planList?.first { it.planId == pair.first } val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Walls>(pair.second) plan?.switchFeature<FeatureModel.Walls>(pair.second)
plan plan
}.flatMap(::getPlan) }.flatMap(::getPlan)
val switchElectric = intent(EstateScreen::switchElectric) val switchElectric = intent(EstateScreen::switchElectric)
.map { pair -> .map { pair ->
val plan = planList?.first { it.planId == pair.first } val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Electric>(pair.second) plan?.switchFeature<FeatureModel.Electric>(pair.second)
plan plan
}.flatMap(::getPlan) }.flatMap(::getPlan)
val showInfo = intent(EstateScreen::showCommonInfo) val showInfo = intent(EstateScreen::showCommonInfo)
.doOnNext { showType = InfoShowType.COMMON_INFO } .doOnNext { restoreModel.showType = InfoShowType.COMMON_INFO }
.map { estate?.commonInfo } .map { restoreModel.estate?.commonInfo }
.map(::mapCommonInfo) .map(::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType, it) } .map { EstateScreenViewState.ShowEstateInfo(restoreModel.showType, it) }
val showExplication = intent(EstateScreen::showExplication) val showExplication = intent(EstateScreen::showExplication)
.doOnNext { showType = InfoShowType.EXPLICATIONS } .doOnNext { restoreModel.showType = InfoShowType.EXPLICATIONS }
.map { planList?.get(it)?.explication } .map { restoreModel.planList?.get(it)?.explication }
.map(::mapCommonInfo) .map(::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType, it) } .map { EstateScreenViewState.ShowEstateInfo(restoreModel.showType, it) }
val onStartTours = intent(EstateScreen::tourCardClicked) val onStartTours = intent(EstateScreen::tourCardClicked)
.map { estate } .map { restoreModel.estate }
.flatMap {estate -> toursInteractor.getEstateTourList(estate) .flatMap {estate -> toursInteractor.getEstateTourList(estate)
.map { EstateScreenViewState.ToursLoaded(it) } .map { EstateScreenViewState.ToursLoaded(it) }
} }
...@@ -202,3 +205,8 @@ enum class InfoShowType{ ...@@ -202,3 +205,8 @@ enum class InfoShowType{
COMMON_INFO, COMMON_INFO,
EXPLICATIONS EXPLICATIONS
} }
data class RestoreModel(var planList: List<PlanPresetModel>? = null,
var estate: EstateModel? = null,
var showType: InfoShowType = InfoShowType.COMMON_INFO)
\ No newline at end of file
...@@ -21,4 +21,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() { ...@@ -21,4 +21,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : EstateScreenViewState() class SomeError(val exception: ExceptionString) : EstateScreenViewState()
class ShowEstateInfo(val showType: InfoShowType, val info:List<DisplayInfoModel>) : EstateScreenViewState() class ShowEstateInfo(val showType: InfoShowType, val info:List<DisplayInfoModel>) : EstateScreenViewState()
class ToursLoaded(val tours:List<TourModel>) : EstateScreenViewState() class ToursLoaded(val tours:List<TourModel>) : EstateScreenViewState()
class RestoreView(val restore:RestoreModel) : EstateScreenViewState()
} }
\ No newline at end of file
...@@ -59,10 +59,14 @@ ...@@ -59,10 +59,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/cancelDownloadButton" android:id="@+id/cancelDownloadButton"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toBottomOf="@+id/downloadProgress" android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="@+id/downloadProgress" android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="32dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="32dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="32dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="32dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.24000001" style="@style/CancelTextDownloader" android:padding="4dp" app:layout_constraintVertical_bias="0.24000001" style="@style/CancelTextDownloader"
android:padding="8dp"
android:paddingStart="8dp" android:paddingEnd="8dp"/> android:paddingStart="8dp" android:paddingEnd="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/playTourCardOpacityLight" android:background="@color/playTourCardOpacityLight"
android:backgroundTintMode="src_atop"
android:clickable="true" android:clickable="true"
android:focusableInTouchMode="true"> android:focusable="true">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="0dp" android:layout_width="0dp"
...@@ -42,10 +43,9 @@ ...@@ -42,10 +43,9 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="false"
android:contentDescription="@string/content_description_close" android:contentDescription="@string/content_description_close"
android:focusable="true" android:focusable="false"
android:focusableInTouchMode="true"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_close_circled" android:src="@drawable/ic_close_circled"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
......
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