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
......@@ -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