Commit 8b13b35c authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

mapping common info

parent 841483ee
...@@ -13,5 +13,7 @@ interface EstateScreen : BigantoBaseContract<EstateScreenViewState> { ...@@ -13,5 +13,7 @@ interface EstateScreen : BigantoBaseContract<EstateScreenViewState> {
fun switchWalls(): Observable<Pair<Int,Boolean>> fun switchWalls(): Observable<Pair<Int,Boolean>>
fun switchFurniture(): Observable<Pair<Int,Boolean>> fun switchFurniture(): Observable<Pair<Int,Boolean>>
fun switchElectric(): Observable<Pair<Int,Boolean>> fun switchElectric(): Observable<Pair<Int,Boolean>>
fun showCommonInfo(): Observable<Int>
fun showExplication(): Observable<Int>
} }
...@@ -8,6 +8,8 @@ import android.webkit.WebView ...@@ -8,6 +8,8 @@ import android.webkit.WebView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isNotEmpty import androidx.core.view.isNotEmpty
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView import butterknife.BindView
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
...@@ -15,6 +17,7 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity ...@@ -15,6 +17,7 @@ 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.FeatureModel import com.biganto.visual.roompark.domain.model.FeatureModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.util.FlatInfoAdapter
import com.google.android.material.switchmaterial.SwitchMaterial import com.google.android.material.switchmaterial.SwitchMaterial
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
...@@ -86,6 +89,9 @@ class EstateScreenController : ...@@ -86,6 +89,9 @@ class EstateScreenController :
@BindView(R.id.flat_plan_webview) @BindView(R.id.flat_plan_webview)
lateinit var planWebView: WebView lateinit var planWebView: WebView
@BindView(R.id.flat_content_recycler_view)
lateinit var flatInfoRecyclerView: RecyclerView
@BindView(R.id.sizes_switch_container) @BindView(R.id.sizes_switch_container)
lateinit var sizesContainer: LinearLayout lateinit var sizesContainer: LinearLayout
...@@ -128,6 +134,11 @@ class EstateScreenController : ...@@ -128,6 +134,11 @@ class EstateScreenController :
} }
private fun bindRecycler() { private fun bindRecycler() {
flatInfoRecyclerView.isNestedScrollingEnabled = true
flatInfoRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
flatInfoRecyclerView.adapter = FlatInfoAdapter()
flatInfoRecyclerView.itemAnimator = null
} }
......
package com.biganto.visual.roompark.presentation.screen.estate package com.biganto.visual.roompark.presentation.screen.estate
import android.app.Activity
import android.content.Context
import androidx.annotation.StringRes
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.EstateInteractor import com.biganto.visual.roompark.domain.interactor.EstateInteractor
import com.biganto.visual.roompark.domain.model.CommonInfoModel
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.FeatureModel import com.biganto.visual.roompark.domain.model.FeatureModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.util.DisplayInfoModel
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
...@@ -19,22 +26,28 @@ import javax.inject.Named ...@@ -19,22 +26,28 @@ import javax.inject.Named
class EstateScreenPresenter @Inject constructor( class EstateScreenPresenter @Inject constructor(
private val interactor: EstateInteractor, private val interactor: EstateInteractor,
private val context: Context,
@Named(SELECTED_ESTATE_ID_KEY) private val estateId:Int @Named(SELECTED_ESTATE_ID_KEY) private val estateId:Int
) )
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() { : BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
private var planList:List<PlanPresetModel>? = null 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) }
private fun getPlan(plan:PlanPresetModel): Observable<EstateScreenViewState> = private fun getPlan(plan: PlanPresetModel): Observable<EstateScreenViewState> =
interactor.getPlan(plan) interactor.getPlan(plan)
.map<EstateScreenViewState> {EstateScreenViewState.LoadPlan(it)} .map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) }
override fun bindIntents() { override fun bindIntents() {
val prefetchCards = interactor.getEstate(estateId) val prefetchCards = interactor.getEstate(estateId)
.doOnNext { estate = it.copy() }
.map { EstateScreenViewState.LoadEstate(it) } .map { EstateScreenViewState.LoadEstate(it) }
val fetchPlans = interactor.getPlanTypes(estateId) val fetchPlans = interactor.getPlanTypes(estateId)
...@@ -43,35 +56,51 @@ class EstateScreenPresenter @Inject constructor( ...@@ -43,35 +56,51 @@ class EstateScreenPresenter @Inject constructor(
val fetchPlan = intent(EstateScreen::planTypesTabSelected) val fetchPlan = intent(EstateScreen::planTypesTabSelected)
.map { planList?.get(it) } .map { planList?.get(it) }
.flatMap{ interactor.getPlan(it) .flatMap {
.map<EstateScreenViewState> {plan -> EstateScreenViewState.LoadPlan(plan) } interactor.getPlan(it)
.startWith(Observable.just<EstateScreenViewState>(EstateScreenViewState.PlanTypeSelected(it))) .map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) }
.startWith(
Observable.just<EstateScreenViewState>(
EstateScreenViewState.PlanTypeSelected(
it
)
)
)
} }
val switchSizes = intent(EstateScreen::switchSizes) val switchSizes = intent(EstateScreen::switchSizes)
.map {pair -> .map { pair ->
val plan = planList?.first{it.planId == pair.first} val plan = 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 = 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 = 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 = planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Electric>(pair.second)
plan
}.flatMap(::getPlan)
val showInfo = intent(EstateScreen::showCommonInfo)
.doOnNext { showType = InfoShowType.COMMON_INFO }
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Electric>(pair.second) plan?.switchFeature<FeatureModel.Electric>(pair.second)
plan plan
}.flatMap(::getPlan) }.flatMap(::getPlan)
...@@ -84,11 +113,50 @@ class EstateScreenPresenter @Inject constructor( ...@@ -84,11 +113,50 @@ class EstateScreenPresenter @Inject constructor(
.mergeWith(switchFurn) .mergeWith(switchFurn)
.mergeWith(switchSizes) .mergeWith(switchSizes)
.mergeWith(switchWalls) .mergeWith(switchWalls)
.doOnError{ Timber.e(it)} .doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(EstateScreenViewState::class.java), EstateScreen::render) subscribeViewState(state.cast(EstateScreenViewState::class.java), EstateScreen::render)
} }
} private fun langString(@StringRes id:Int) = context.resources.getString(id)
\ No newline at end of file
private fun langString(@StringRes id:Int,vararg args:Any) =
context.resources.getString(id,args)
private fun mapCommonInfo(info: CommonInfoModel) {
val r = arrayListOf<DisplayInfoModel>()
info.building.let {
r.add(DisplayInfoModel(langString(R.string.building),"$it"))
}
info.section_begin.let {
r.add(DisplayInfoModel(langString(R.string.section_begin),"$it"))
}
r.add(DisplayInfoModel(langString(R.string.floor),"${info.floor}/${info.floor_max}"))
info.area?.let {
r.add(DisplayInfoModel(langString(R.string.area),langString(R.string.area_value,it)))
}
info.area_living?.let {
r.add(DisplayInfoModel(
langString(R.string.area_living),langString(R.string.area_value,it))
)
}
info.rooms?.let {r.add(DisplayInfoModel(langString(R.string.rooms),"$it"))}
info.kind?.let {r.add(DisplayInfoModel(langString(R.string.flat_kind), it))}
info.decoration?.let {r.add(DisplayInfoModel(langString(R.string.flat_decoration), it))}
info.ceiling?.let {r.add(DisplayInfoModel(langString(R.string.ceiling)
, langString(R.string.meters_value,it)))
}
info.windows_face?.let {r.add(DisplayInfoModel(langString(R.string.window_face), it))}
info.direction?.let {r.add(DisplayInfoModel(langString(R.string.direction), it))}
}
}
private enum class InfoShowType{
COMMON_INFO,
EXPLICATIONS
}
package com.biganto.visual.roompark.presentation.screen.estate.util
import android.view.View
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.google.android.material.textview.MaterialTextView
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
class FlatInfoAdapter : CommonRecyclerAdapter<FlatInfoViewHolder, DisplayInfoModel>() {
override val vhKlazz = FlatInfoViewHolder::class
override fun getVhLayout(): Int = R.layout.flate_measure_info_viewholder
}
class FlatInfoViewHolder(itemView: View) : CommonViewHolder<DisplayInfoModel>(itemView) {
@BindView(R.id.flat_measure_description)
lateinit var infoTitle:MaterialTextView
@BindView(R.id.flat_measure_value)
lateinit var infoValue:MaterialTextView
override fun onViewBound(model: DisplayInfoModel) {
infoTitle.text = model.langTitle
infoValue.text = model.langValue
}
}
data class DisplayInfoModel(val langTitle:String, val langValue:String)
\ No newline at end of file
...@@ -270,7 +270,8 @@ ...@@ -270,7 +270,8 @@
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/switch_flat_content_tab" /> app:layout_constraintTop_toBottomOf="@+id/switch_flat_content_tab"
tools:listitem="@layout/flate_measure_info_viewholder" />
<include <include
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
style="@style/Accent_Minor_TextView.Default" style="@style/Accent_Minor_TextView.Default"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="4 000 000" /> android:text="4 000 000" />
......
...@@ -51,6 +51,19 @@ ...@@ -51,6 +51,19 @@
\nPassword at least %d symbols</string> \nPassword at least %d symbols</string>
<string name="feeds_tab_divider">/</string> <string name="feeds_tab_divider">/</string>
<string name="unauthorized_user_request">Пользователь не авторизован</string> <string name="unauthorized_user_request">Пользователь не авторизован</string>
<string name="building">Корпус</string>
<string name="section_begin">Секция</string>
<string name="floor">Этаж</string>
<string name="area">Общая площадь</string>
<string name="area_value">%.1f м\u00B2</string>
<string name="area_living">Жилая площадь</string>
<string name="rooms">Кол-во комнат</string>
<string name="flat_kind">Тип квартиры</string>
<string name="flat_decoration">Наличие отделки</string>
<string name="ceiling">Высота потолков</string>
<string name="meters_value">%.1f м</string>
<string name="window_face">Вид из окон</string>
<string name="direction">Сторона света</string>
<!--endregion--> <!--endregion-->
</resources> </resources>
Exception: STATUS_ACCESS_VIOLATION at rip=7FFC53A72768
rax=00007FFC53A72768 rbx=0000000000191500 rcx=0000000004858270
rdx=0000000000000009 rsi=0000000000000019 rdi=00000000000C5398
r8 =000000000019CD01 r9 =00000000000C5348 r10=0000000000000000
r11=00000000008CC690 r12=0000000000000000 r13=00007FFCA7666120
r14=00000000048A0FE0 r15=0000000000000002
rbp=0000000000000001 rsp=00000000008CC758
program=C:\Program Files\Git\usr\bin\mintty.exe, pid 19556, thread
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
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