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

fix deals restore

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