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

fix deals restore

parent 80becc0d
...@@ -107,14 +107,13 @@ class DealScreenController : ...@@ -107,14 +107,13 @@ class DealScreenController :
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
private var servedDeal : DealModel? = null
override fun onAttach(view: View) { override fun onAttach(view: View) {
super.onAttach(view) super.onAttach(view)
detachDisposable.addAll( detachDisposable.addAll(
toFlatView.clicks() toFlatView.clicks()
.map { servedDeal?.estate?.id?: -1000} .map { dealModel?.estate?.id?: -1000}
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe { .subscribe {
Timber.d("got card clicked $it") Timber.d("got card clicked $it")
...@@ -217,6 +216,7 @@ class DealScreenController : ...@@ -217,6 +216,7 @@ class DealScreenController :
silentCheck = true silentCheck = true
sw.isChecked = viewState.subState sw.isChecked = viewState.subState
} }
toolBar.headerToolbar.invalidate()
} }
private fun render(viewState: DealScreenViewState.SubscriptionError) { private fun render(viewState: DealScreenViewState.SubscriptionError) {
...@@ -241,6 +241,8 @@ class DealScreenController : ...@@ -241,6 +241,8 @@ class DealScreenController :
silentCheck = true silentCheck = true
sw.isChecked != sw.isChecked sw.isChecked != sw.isChecked
} }
viewState.restore.deal?.let { setUpDeal(it) }
} }
private fun render(viewState: DealScreenViewState.ToursLoaded) { private fun render(viewState: DealScreenViewState.ToursLoaded) {
...@@ -263,51 +265,56 @@ class DealScreenController : ...@@ -263,51 +265,56 @@ class DealScreenController :
private var dealModel:DealModel? = null private var dealModel:DealModel? = null
private fun render(viewState: DealScreenViewState.LoadDeal) { private fun setUpDeal(deal:DealModel){
servedDeal = viewState.estate dealModel = deal
startTourView.setGone(servedDeal?.estate?.multitourId == null) dealModel?.let {
dealTitle.text = resources?.getString(
viewState.estate.estate.type.typeDoubleString(), startTourView.setGone(it.estate.multitourId == null)
viewState.estate.estate.number dealTitle.text = resources?.getString(
) it.estate.type.typeDoubleString(),
it.estate.number
)
info1.title.text = resources?.getString(R.string.building) info1.title.text = resources?.getString(R.string.building)
info1.text.text = viewState.estate.estate.commonInfo?.building.toString() info1.text.text = it.estate.commonInfo?.building.toString()
info2.title.text = resources?.getString(R.string.section_begin) info2.title.text = resources?.getString(R.string.section_begin)
info2.text.text = viewState.estate.estate.commonInfo?.section_begin.toString() info2.text.text = it.estate.commonInfo?.section_begin.toString()
info3.title.text = resources?.getString(R.string.floor) info3.title.text = resources?.getString(R.string.floor)
info3.text.text = viewState.estate.estate.commonInfo?.floor.toString() info3.text.text = it.estate.commonInfo?.floor.toString()
info4.title.text = resources?.getString(R.string.area) info4.title.text = resources?.getString(R.string.area)
info4.text.text = info4.text.text =
resources?.getString(R.string.area_value,viewState.estate.estate.commonInfo?.area) resources?.getString(R.string.area_value,it.estate.commonInfo?.area)
dealSum.text = viewState.estate.opportunitySum.toRubly() dealSum.text = it.opportunitySum.toRubly()
dealPayed.text = viewState.estate.paymentSum.toRubly() dealPayed.text = it.paymentSum.toRubly()
dealSumToPay.text = viewState.estate.amount_pay_sum.toRubly() dealSumToPay.text = it.amount_pay_sum.toRubly()
viewState.estate.estate.multitourPreview?.let { it.estate.multitourPreview?.let {url ->
Glide.with(tourScreen) Glide.with(tourScreen)
.load(it) .load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL) .diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tourScreen) .into(tourScreen)
}
toolBar.setToolbar(HeaderToolbarModel(
true
,resources?.getString(R.string.deal_back_chevron_title)
,null
,true)
)
} }
}
dealModel = viewState.estate private fun render(viewState: DealScreenViewState.LoadDeal) {
toolBar.setToolbar(HeaderToolbarModel( setUpDeal(viewState.estate)
true
,resources?.getString(R.string.deal_back_chevron_title)
,null
,true)
)
progressLayout.removeAllViews() progressLayout.removeAllViews()
viewState.statusList.forEach { viewState.statusList.forEach {
val statusLayout = LayoutInflater.from(activity) val statusLayout = LayoutInflater.from(activity)
...@@ -316,9 +323,7 @@ class DealScreenController : ...@@ -316,9 +323,7 @@ class DealScreenController :
,false) ,false)
as LinearLayout as LinearLayout
Timber.d("layouted: $statusLayout")
val statusCeil = statusLayout.findViewById<StatusProgressCeil>(R.id.status) val statusCeil = statusLayout.findViewById<StatusProgressCeil>(R.id.status)
Timber.d("layouted ceail : $statusCeil")
val position = it.orderId val position = it.orderId
val statusCount = viewState.statusList.size val statusCount = viewState.statusList.size
...@@ -333,11 +338,11 @@ class DealScreenController : ...@@ -333,11 +338,11 @@ class DealScreenController :
statusCeil.invalidate() statusCeil.invalidate()
val statusTitle = statusLayout.findViewById<MaterialTextView>(R.id.title) val statusTitle = statusLayout.findViewById<MaterialTextView>(R.id.title)
Timber.d("layouted statusTitle : $statusTitle")
statusTitle.text = it.shortTitle statusTitle.text = it.shortTitle
progressLayout.addView(statusLayout) progressLayout.addView(statusLayout)
} }
progressLayout.invalidate() progressLayout.invalidate()
} }
private fun getComponent() = DaggerDealScreenComponent.factory() private fun getComponent() = DaggerDealScreenComponent.factory()
......
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