Commit 667d20b1 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

deal read flag provided

parent ef7eb238
......@@ -16,6 +16,7 @@ import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
......@@ -241,6 +242,10 @@ class EstateRepository @Inject constructor(
}
override fun setDealRead(dealId: String): Completable =
db.setDealReadState(dealId,true)
private fun fetchEstateApi(building: Int,number:Int)=
......
......@@ -33,4 +33,5 @@ interface IDb {
fun upsertEstate(entity: EstateEntity)
fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity>
fun setArticleReadState(id: Int, state: Boolean): Completable
fun setDealReadState(id: String, state: Boolean): Completable
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.*
import com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
import dagger.Module
import dagger.Provides
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.Single
import io.requery.Persistable
......@@ -158,11 +159,20 @@ class RequeryRepository @Inject constructor(
.and(EstateEntity.FAVORITE.eq(true))
.get().observable()
override fun setArticleReadState(id:Int,state:Boolean) =
override fun setArticleReadState(id:Int,state:Boolean): Completable =
store.update(ArticleEntity::class)
.set(ArticleEntity.ANNOUNCE,"")
.set(ArticleEntity.READ,state)
.where(ArticleEntity.ID.eq(id))
.get()
.single()
.ignoreElement()
override fun setDealReadState(id:String,state:Boolean): Completable =
store.update(DealEntity::class)
.set(DealEntity.READ,state)
.where(DealEntity.ID.eq(id))
.get()
.single()
.ignoreElement()
}
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import io.reactivex.Completable
import io.reactivex.Observable
/**
......@@ -27,4 +28,5 @@ interface DealContract{
fun getDeals(): Observable<List<DealModel>>
fun fetchEstate(building: Int, number: Int): Observable<EstateModel>
fun setDealRead(dealId: String): Completable
}
\ No newline at end of file
......@@ -23,11 +23,10 @@ class DealInteractor @Inject constructor(
fun getStatusListSync() = statusList.asSequence().sortedBy{ it.orderId }.toList()
fun getFakeDeal(): Observable<DealModel> = Observable.just(dealParkign)
fun setDealRead(id:String) = useCase.setDealRead(id)
companion object{
val statusList = arrayListOf<StatusModel>(
StatusModel(
1,
......@@ -86,239 +85,4 @@ class DealInteractor @Inject constructor(
"Договор выдан"
)
)
val dealParkign = DealModel(
amount_pay_sum = 4535860,
estate = EstateModel(
albumId = 10,
commonInfo = CommonInfoModel(
area = 55.4f,
area_living = 31.5f,
building = 1,
ceiling = 2.95f,
decoration = "\u0411\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u043a\u0438, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u043a\u0430",
dependent = null,
direction = "\u0441\u0435\u0432\u0435\u0440\u043e-\u0437\u0430\u043f\u0430\u0434,\u044e\u0433\u043e-\u0432\u043e\u0441\u0442\u043e\u043a",
discount = 5.0f,
discount_amount = 6925215,
floor = 10,
floor_max = 22,
kind = "2\u043a-2\u0440",
price = 7289700,
price_meter = 131583,
rooms = 2,
section_begin = 14,
windows_face = "\u0414\u0432\u043e\u0440 \u0438 \u0423\u043b\u0438\u0446\u0430"
),
// explications = arrayListOf(ExplicationListModel(
// items = arrayListOf(
// ExplicationModel(
// area = 16.9f,
// living = true,
// stateTitle = "\u0413\u043e\u0441\u0442\u0438\u043d\u0430\u044f"
// ),ExplicationModel(
// area = 14.6f,
// living = true,
// stateTitle = "\u0421\u043f\u0430\u043b\u044c\u043d\u044f"
// ),ExplicationModel(
// area = 10.8f,
// living = false,
// stateTitle = "\u041a\u0443\u0445\u043d\u044f"
// ),ExplicationModel(
// area = 3.6f,
// living = false,
// stateTitle = "\u041a\u043e\u0440\u0438\u0434\u043e\u0440"
// ),ExplicationModel(
// area = 3.4f,
// living = false,
// stateTitle = "\u0421\u0430\u043d\u0443\u0437\u0435\u043b"
// ),ExplicationModel(
// area = 2.8f,
// living = false,
// stateTitle = "\u041f\u0440\u0438\u0445\u043e\u0436\u0430\u044f"
// ),ExplicationModel(
// area = 1.9f,
// living = false,
// stateTitle = "\u0421\u0430\u043d\u0443\u0437\u0435\u043b"
// ),ExplicationModel(
// area = 1.4f,
// living = false,
// stateTitle = "\u041b\u043e\u0434\u0436\u0438\u044f"
// )
// ),
// planId = 0
// ),
// ExplicationListModel(
// items = arrayListOf(
// ExplicationModel(
// area = 16.2f,
// living = true,
// stateTitle = "\u0413\u043e\u0441\u0442\u0438\u043d\u0430\u044f"
// ),ExplicationModel(
// area = 13.7f,
// living = true,
// stateTitle = "\u0421\u043f\u0430\u043b\u044c\u043d\u044f"
// ),ExplicationModel(
// area = 10.2f,
// living = false,
// stateTitle = "\u041a\u0443\u0445\u043d\u044f"
// ),ExplicationModel(
// area = 4.3f,
// living = false,
// stateTitle = "\u041a\u043e\u0440\u0438\u0434\u043e\u0440"
// ),ExplicationModel(
// area = 4.2f,
// living = false,
// stateTitle = "\u041f\u0440\u0438\u0445\u043e\u0436\u0430\u044f"
// ),ExplicationModel(
// area = 4.1f,
// living = false,
// stateTitle = "\u0421\u0430\u043d\u0443\u0437\u0435\u043b"
// ),ExplicationModel(
// area = 1.4f,
// living = false,
// stateTitle = "\u041b\u043e\u0434\u0436\u0438\u044f"
// ),ExplicationModel(
// area = 1.3f,
// living = false,
// stateTitle = "\u0421\u0430\u043d\u0443\u0437\u0435\u043b"
// )
// ),
// planId = 1
// )
// ),
id = 75,
multitourId = 4911,
number = "1086",
planJPG = PlanModel(
height = 549,
url = "/assets/estates/plan_jpg/00/00/00/75-9027cf.jpeg",
width = 1280
),
planPNG = PlanModel(
height = 180,
url = "/assets/estates/plan_png/00/00/00/75-92ed97.png",
width = 420
),
type = FlatType.valueOf("flat".toUpperCase()),
url = "https://stage.room-park.ru:38386/choose/flat/1/14/1086/"
),
estate_id = "2156",
id = "1562623",
managerName = "\u0411\u043e\u0441\u043e\u0432\u0430, \u0418\u0440\u0438\u043d\u0430",
opportunitySum= 5035860,
paymentSum= 500000,
statusId = 10
)
val dealFlat = DealModel(
amount_pay_sum = 5118160,
estate = EstateModel(
albumId= 10,
commonInfo= CommonInfoModel(
area = 61.2f,
area_living = 30.3f,
building = 1,
ceiling = 2.95f,
decoration = "Без отделки, свободная планировка",
dependent = null,
direction = "север,восток",
discount = 5.0f,
discount_amount = 7356325,
floor = 10,
floor_max = 15,
kind = "2к-4л",
price = 7743500,
price_meter = 126527,
rooms = 2,
section_begin = 2,
windows_face = "Двор"
),
// explications = arrayListOf(
// ExplicationListModel(
// items = arrayListOf(
// ExplicationModel(
// area = 15.8f,
// living = true,
// stateTitle = "Гостиная"
// ),ExplicationModel(
// area = 14.5f,
// living = true,
// stateTitle = "Спальня"
// ),ExplicationModel(
// area = 20.2f,
// living = false,
// stateTitle = "Кухня"
// ),ExplicationModel(
// area = 5.0f,
// living = false,
// stateTitle = "Прихожая"
// ),ExplicationModel(
// area = 4.1f,
// living = false,
// stateTitle = "Санузел"
// ),ExplicationModel(
// area = 1.6f,
// living = false,
// stateTitle = "Лоджия"
// )
// ),
// planId = 0
// ),
// ExplicationListModel(
// items = arrayListOf(
// ExplicationModel(
// area = 15.5f,
// living = true,
// stateTitle = "Спальня"
// ),ExplicationModel(
// area = 14.5f,
// living = true,
// stateTitle = "Спальня"
// ),ExplicationModel(
// area = 20.2f,
// living = false,
// stateTitle = "Кухня-гостиная"
// ),ExplicationModel(
// area = 5.3f,
// living = false,
// stateTitle = "Прихожая"
// ),ExplicationModel(
// area = 4.1f,
// living = false,
// stateTitle = "Санузел"
// ),ExplicationModel(
// area = 1.6f,
// living = false,
// stateTitle = "Лоджия"
// )
// ),
// planId = 1
// )
// ),
id = 1201,
multitourId = 6500,
number = "88",
planJPG = PlanModel(
height = 720,
url = "/assets/estates/plan_jpg/00/00/04/1201-52d64f.jpeg",
width = 785
),
planPNG = PlanModel(
height = 292,
url = "/assets/estates/plan_png/00/00/04/1201-91169f.png",
width = 318
),
type = FlatType.valueOf("flat".toUpperCase()),
url = "https://stage.room-park.ru:38386/choose/flat/1/2/88/"
),
estate_id = "6222",
id = "42341",
managerName = "Босова, Ирина",
opportunitySum = 5618160,
paymentSum = 500000,
statusId = 10
)
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ data class DealPreviewModel(
val dealTourIds : List<Int?>?,
val isViewed: Boolean = true,
val tourPreview: String?,
val isRead: Boolean,
val statusList : List<StatusModel>
){
constructor(data:Pair<DealModel,List<StatusModel>>) : this(
......@@ -36,6 +37,7 @@ data class DealPreviewModel(
arrayListOf<Int?>(data.first.estate.multitourId),
false,
data.first.estate.multitourPreview,
data.first.isRead,
data.second
)
}
......
......@@ -30,6 +30,7 @@ data class DealModel(
val amount_pay_sum:Int,
val statusId:Int,
val managerName: String,
val isRead: Boolean,
val estate:EstateModel
)
......@@ -41,6 +42,7 @@ fun fromEntity(entity:DealEntity) = DealModel(
amount_pay_sum = entity.amountPaySum,
statusId = entity.statusId,
managerName = entity.managerName,
isRead = entity.read,
estate = fromEntity(entity.estate as EstateEntity)
)
......
......@@ -13,5 +13,7 @@ class DealseUseCase @Inject constructor(
fun getDeals() = contract.getDeals()
fun setDealRead(id:String) = contract.setDealRead(id)
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.article
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.ArticleInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
......@@ -29,8 +30,7 @@ class ArticleScreenPresenter @Inject constructor(
.map { ArticleScreenViewState.ArticleLoaded(it) }
val setRead = interactor.setArticleRead(selectedArticleId)
.andThen({ ArticleScreenViewState.Idle()})
.andThen(Observable.just(ArticleScreenViewState.Idle()))
val state = restoreStateObservable
......
......@@ -4,11 +4,11 @@ import android.content.Context
import androidx.annotation.StringRes
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.DealInteractor
import com.biganto.visual.roompark.domain.interactor.EstateInteractor
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.InfoShowType
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
......@@ -22,7 +22,6 @@ import javax.inject.Named
class DealScreenPresenter @Inject constructor(
private val interactor: DealInteractor,
private val interactor2: EstateInteractor,
private val context: Context,
@Named(SELECTED_DEAL_ID_KEY) private val dealId:String
)
......@@ -45,8 +44,13 @@ class DealScreenPresenter @Inject constructor(
DealScreenViewState.LoadDeal(deal ,interactor.getStatusListSync())
}
val setRead = interactor.setDealRead(dealId)
.andThen(Observable.just(DealScreenViewState.Idle()))
val state = restoreStateObservable
.mergeWith(fetchDeal)
.mergeWith(setRead)
.doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.domain.model.typeDoubleString
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.biganto.visual.roompark.util.extensions.toRubly
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
......@@ -68,10 +69,15 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
@BindView(R.id.start_tour_image_view) lateinit var tourScreen:RoundedImageView
@BindView(R.id.deal_read) lateinit var dealReadFlag:RoundedImageView
val onStartFlatObs: Observable<Int?> get() = startFlat.clicks().map { bindedModel.estateId }
val onStartTourObs: Observable<Int?> get() = startTour.clicks().map { bindedModel.tourId }
override fun onViewBound(model: DealPreviewModel) {
dealReadFlag.setGone(model.isRead)
estateTitle.text =
itemView.context.resources?.getString(model.type.typeDoubleString(),model.name)
renderCommonInfo(model)
......@@ -93,6 +99,8 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout.invalidate()
model.tourPreview?.let {
Glide.with(tourScreen)
.load(it)
......
......@@ -4,26 +4,25 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_margin="4dp"
>
<FrameLayout
android:elevation="10dp"
android:id="@+id/feed_read"
android:id="@+id/deal_read"
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/new_feed_icon"
android:backgroundTint="@color/colorAccent"
android:visibility="visible"
android:layout_margin="2dp"/>
android:layout_margin="6dp"/>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_margin="12dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
app:cardElevation="6dp"
......
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