Commit 102fada9 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

deal status progress

deal card
parent 4638bb65
......@@ -12,7 +12,7 @@ class DealsInteractor @Inject constructor(
){
fun fetchDeals() = Single.just(arrayListOf(dealFlat, dealParkign))
fun getStatusList() = Single.just(statusList.sortBy { it.orderId })
fun getStatusList() = Single.just(statusList.sortedBy{ it.orderId })
companion object{
......
package com.biganto.visual.roompark.presentation.screen.deals
import com.biganto.visual.roompark.conductor.BigantoBaseContract
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.StatusModel
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
......@@ -9,3 +11,37 @@ import com.biganto.visual.roompark.conductor.BigantoBaseContract
interface DealsScreen : BigantoBaseContract<DealsScreenViewState> {
}
data class DealPreviewModel(
val id:String,
val type:String,
val name:String,
val building:Int?,
val section:Int?,
val floor:Int?,
val area: Float?,
val statusNo : Int,
val dealSum : Int,
val dealPayout : Int,
val dealToPay : Int,
val dealTourIds : List<Int?>?,
val isViewed: Boolean = true,
val statusList : List<StatusModel>
){
constructor(data:Pair<DealModel,List<StatusModel>>) : this(
data.first.id,
data.first.estate.type,
data.first.estate.number,
data.first.estate.commonInfo?.building,
data.first.estate.commonInfo?.section_begin,
data.first.estate.commonInfo?.floor,
data.first.estate.commonInfo?.area,
data.first.statusId,
data.first.opportunitySum,
data.first.paymentSum,
data.first.amount_pay_sum,
arrayListOf<Int?>(data.first.estate.multitourId),
false,
data.second
)
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.deals
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter
import com.biganto.visual.roompark.view_utils.grid.CeilsDecoration
import timber.log.Timber
import javax.inject.Inject
......@@ -22,12 +27,30 @@ class DealsScreenController :
getComponent()
}
@BindView(R.id.favorites_cards_recycler_view)
lateinit var favoritesRecyclerView: RecyclerView
private fun bindRecycler() {
favoritesRecyclerView.isNestedScrollingEnabled = true
favoritesRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
favoritesRecyclerView.adapter = DealsListAdapter()
favoritesRecyclerView.itemAnimator = null
if (favoritesRecyclerView.itemDecorationCount == 0)
favoritesRecyclerView.addItemDecoration(
CeilsDecoration(1
, resources?.getDimensionPixelSize(R.dimen.ceil_grid_padding))
)
}
@Inject
override lateinit var injectedPresenter: DealsScreenPresenter
override fun onViewBound(v: View) {
bindRecycler()
}
override fun render(viewState: DealsScreenViewState) {
......@@ -35,6 +58,7 @@ class DealsScreenController :
Timber.d("Render state $viewState")
when(viewState){
is DealsScreenViewState.Idle -> render(viewState)
is DealsScreenViewState.DealsLoaded -> render(viewState)
}
}
......@@ -42,6 +66,12 @@ class DealsScreenController :
}
private fun render(viewState: DealsScreenViewState.DealsLoaded){
(favoritesRecyclerView.adapter as DealsListAdapter).addItems(viewState.items)
}
private fun getComponent() = DaggerDealsScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this)
......
......@@ -20,7 +20,17 @@ class DealsScreenPresenter @Inject constructor(
override fun bindIntents() {
val getStatusList = interactor.getStatusList()
val fetchDeals = interactor.fetchDeals()
.flatMap { deals ->
getStatusList
.map { List(deals.size) { index -> DealPreviewModel(Pair(deals[index], it)) } }
}
.map(DealsScreenViewState::DealsLoaded)
val state = restoreStateObservable
.mergeWith(fetchDeals)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -9,4 +9,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed class DealsScreenViewState : BigantoBaseViewState() {
class Idle : DealsScreenViewState()
}
\ No newline at end of file
class DealsLoaded(val items:List<DealPreviewModel>) : DealsScreenViewState()
}
package com.biganto.visual.roompark.presentation.screen.deals.util
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import butterknife.ButterKnife
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.CommonInfoModel
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.presentation.screen.deals.DealPreviewModel
import com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
class DealsListAdapter : RecyclerView.Adapter<CamListViewHolder>() {
class DealsListAdapter : RecyclerView.Adapter<DealViewHolder>() {
private var list: MutableList<DealModel> = mutableListOf()
private var list: MutableList<DealPreviewModel> = mutableListOf()
fun addItems(list:List<DealModel>){
fun addItems(list:List<DealPreviewModel>){
this.list.clear()
this.list.addAll(list)
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CamListViewHolder =
CamListViewHolder(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DealViewHolder =
DealViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.favorite_card_viewholder, parent, false)
.inflate(R.layout.deal_card_viewholder, parent, false)
)
override fun getItemCount(): Int = list.size
override fun onBindViewHolder(holder: CamListViewHolder, position: Int) {
override fun onBindViewHolder(holder: DealViewHolder, position: Int) {
holder.bindModel(list[position])
}
}
class CamListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@BindView(R.id.object_card_title) lateinit var estateTitle: TextView
@BindView(R.id.deal_card_header) lateinit var estateTitle: TextView
@BindView(R.id.common_info_block) lateinit var commonInfo:View
@BindView(R.id.start_tour_button) lateinit var startTour:View
......@@ -54,6 +59,8 @@ class CamListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@BindView(R.id.deal_payed_value_text_view) lateinit var dealPayed:TextView
@BindView(R.id.deal_to_pay_value_text_view) lateinit var dealSumToPay:TextView
@BindView(R.id.progress_holder) lateinit var statusContainer:LinearLayout
fun typeName(type:String) = when(type){
"flat" -> "КВАРТИРА"
......@@ -66,29 +73,29 @@ class CamListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
ButterKnife.bind(this, itemView)
}
fun bindModel(deal: DealModel) {
val model = deal.estate
val fullObjName = "${typeName(model.type)}\n${model.number}"
fun bindModel(deal: DealPreviewModel) {
val fullObjName = "${typeName(deal.type)}\n${deal.name}"
estateTitle.text = fullObjName
if (model.commonInfo == null) commonInfo.visibility = View.GONE
else {commonInfo.visibility = View.VISIBLE; renderCommonInfo(model.commonInfo)}
renderCommonInfo(deal)
if (model.type == "flat") startTour.visibility = View.VISIBLE
if (deal.dealTourIds.isNullOrEmpty()) startTour.visibility = View.VISIBLE
else startTour.visibility = View.GONE
dealSum.text = deal.opportunitySum.toRubly()
dealPayed.text = deal.paymentSum.toRubly()
dealSumToPay.text = deal.amount_pay_sum.toRubly()
dealSum.text = deal.dealSum.toRubly()
dealPayed.text = deal.dealPayout.toRubly()
dealSumToPay.text = deal.dealToPay.toRubly()
createStatusView(statusContainer,deal.statusList,deal.statusNo,false)
}
fun renderCommonInfo(info:CommonInfoModel){
private fun renderCommonInfo(info:DealPreviewModel){
if (info.building == null) info1.visibility = View.GONE
else { info1.title().text = "Корпус"; info1.text().text = info.building.toString()}
if (info.section_begin == null) info1.visibility = View.GONE
else { info2.title().text = "Секция"; info2.text().text = info.section_begin.toString()}
if (info.section == null) info1.visibility = View.GONE
else { info2.title().text = "Секция"; info2.text().text = info.section.toString()}
if (info.floor == null) info1.visibility = View.GONE
else { info3.title().text = "Этаж"; info3.text().text = info.floor.toString()}
......@@ -103,6 +110,45 @@ class CamListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
return String.format("%,d \u20BD",this).replace(',',' ')
}
}
fun createStatusView(container:ViewGroup,list:List<StatusModel>,currentStatus:Int, isVertical:Boolean){
container.removeAllViews()
val scale = container.resources.displayMetrics.density.toDouble()
val param24dp = kotlin.math.ceil(24 * scale).toInt()
val wrapContent = ViewGroup.LayoutParams.WRAP_CONTENT
(container as LinearLayout).weightSum =10f
list.sortedBy { it.orderId }.forEach{
val ceil = LayoutInflater.from(container.context)
.inflate(R.layout.status_view,container,false) as StatusProgressCeil
ceil.layoutParams.height = if (isVertical) wrapContent else param24dp
ceil.layoutParams.width = if (isVertical) param24dp else wrapContent
(ceil.layoutParams as LinearLayout.LayoutParams).weight = 1f
(ceil.layoutParams as LinearLayout.LayoutParams).gravity = Gravity.BOTTOM
Timber.d("${it.orderId-1} != ${list.size}")
ceil.setHasEnd(it.orderId != list.size)
ceil.setHasStart(it.orderId>1)
Timber.d("${it.orderId} == ${currentStatus}")
ceil.setIsEnabled(it.orderId <= currentStatus)
Timber.d("${it.orderId} <= ${currentStatus}")
ceil.setNext(it.orderId < currentStatus)
if (it.orderId > currentStatus)
ceil.setAnimState(StatusProgressAnimationState.DISABLE)
ceil.invalidate()
container.addView(ceil)
Timber.d("created view : $param24dp")
}
container.invalidate()
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ import com.biganto.visual.roompark.domain.model.EstateModel
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
class FavoritesListAdapter : RecyclerView.Adapter<DealViewHolder>() {
class FavoritesListAdapter : RecyclerView.Adapter<FavoriteViewHolder>() {
private var list: MutableList<EstateModel> = mutableListOf()
......@@ -25,21 +25,21 @@ class FavoritesListAdapter : RecyclerView.Adapter<DealViewHolder>() {
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DealViewHolder =
DealViewHolder(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteViewHolder =
FavoriteViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.deal_card_viewholder, parent, false)
.inflate(R.layout.favorite_card_viewholder, parent, false)
)
override fun getItemCount(): Int = list.size
override fun onBindViewHolder(holder: DealViewHolder, position: Int) {
override fun onBindViewHolder(holder: FavoriteViewHolder, position: Int) {
holder.bindModel(list[position])
}
}
class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class FavoriteViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@BindView(R.id.object_card_title) lateinit var estateTitle: TextView
@BindView(R.id.common_info_block) lateinit var commonInfo:View
......
......@@ -26,17 +26,23 @@ class StatusProgressCeil @JvmOverloads constructor(
private var animateState:StatusProgressAnimationState =
StatusProgressAnimationState.fromInt(array.getInt(R.styleable.StatusProgressCeil_anim_state,1))
private val hasStart:Boolean =
private var hasStart:Boolean =
array.getBoolean(R.styleable.StatusProgressCeil_hasStart,false)
private val hasEnd:Boolean =
private var hasEnd:Boolean =
array.getBoolean(R.styleable.StatusProgressCeil_hasEnd,false)
private val isEnable:Boolean =
private var isEnable:Boolean =
array.getBoolean(R.styleable.StatusProgressCeil_isEnable,false)
private val nextEnable:Boolean =
private var nextEnable:Boolean =
array.getBoolean(R.styleable.StatusProgressCeil_nextEnable,false)
val animationTimeMills:Long = 80L
var lastAnimateStateChanged:Long = 0L
fun setHasStart(has:Boolean) { hasStart = has }
fun setHasEnd(has:Boolean) { hasEnd = has }
fun setIsEnabled(isEnable:Boolean) { this.isEnable = isEnable}
fun setNext(nextisEnable:Boolean) { nextEnable = nextisEnable }
fun setAnimState(state:StatusProgressAnimationState) { animateState = state }
private val animationTimeMills:Long = 80L
private var lastAnimateStateChanged:Long = 0L
val ifAnimateEnd:Boolean get(){
return (System.currentTimeMillis()-lastAnimateStateChanged) > animationTimeMills
......
......@@ -26,48 +26,64 @@
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<include
android:id="@+id/info_ceil_1"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/common_info_block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:orientation="horizontal">
<include
android:id="@+id/info_ceil_2"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/info_ceil_1"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/info_ceil_3"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/info_ceil_2"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/info_ceil_4"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/info_ceil_3"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<include
android:id="@+id/info_ceil_4"
layout="@layout/info_ceil_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<include layout="@layout/test_progress_status"
android:layout_height="wrap_content"
</LinearLayout>
<LinearLayout
android:id="@+id/progress_holder"
android:orientation="horizontal"
android:layout_height="60dp"
android:layout_width="match_parent"
/>
android:background="@drawable/gradient_background_accent"
>
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="24dp"
android:layout_height="wrap_content"/>
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="24dp"
android:layout_height="wrap_content"/>
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="24dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
......@@ -166,6 +182,7 @@
</LinearLayout>
<include
android:id="@+id/start_tour_button"
layout="@layout/start_tour_viewholder"
android:layout_width="match_parent"
android:layout_height="64dp"
......
......@@ -11,7 +11,6 @@
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="24dp"
android:scaleType="fitEnd"
app:direction="vertical"
app:hasEnd="true"
app:hasStart="false"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sum"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="@color/colorCheckListGradientEnd"
android:orientation="horizontal"
android:weightSum="10">
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="false"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:id="@+id/statusProgressCeil2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:id="@+id/statusProgressCeil4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:id="@+id/statusProgressCeil5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:id="@+id/statusProgressCeil6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:id="@+id/statusProgressCeil3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="true" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:direction="horizontal"
app:hasEnd="true"
app:hasStart="true"
app:isEnable="true"
app:nextEnable="false" />
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitEnd"
app:anim_state="disable"
app:direction="horizontal"
app:hasEnd="false"
app:hasStart="true"
app:isEnable="false"
app:nextEnable="false" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</com.biganto.visual.roompark.view_utils.status_progress_view.StatusProgressCeil>
\ 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