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 ...@@ -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.EstateModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.domain.model.fromEntity import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
...@@ -241,6 +242,10 @@ class EstateRepository @Inject constructor( ...@@ -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)= private fun fetchEstateApi(building: Int,number:Int)=
......
...@@ -33,4 +33,5 @@ interface IDb { ...@@ -33,4 +33,5 @@ interface IDb {
fun upsertEstate(entity: EstateEntity) fun upsertEstate(entity: EstateEntity)
fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity> fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity>
fun setArticleReadState(id: Int, state: Boolean): Completable 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.* ...@@ -6,6 +6,7 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.*
import com.biganto.visual.roompark.di.dagger.DATABASE_VERSION import com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import io.requery.Persistable import io.requery.Persistable
...@@ -158,11 +159,20 @@ class RequeryRepository @Inject constructor( ...@@ -158,11 +159,20 @@ class RequeryRepository @Inject constructor(
.and(EstateEntity.FAVORITE.eq(true)) .and(EstateEntity.FAVORITE.eq(true))
.get().observable() .get().observable()
override fun setArticleReadState(id:Int,state:Boolean) = override fun setArticleReadState(id:Int,state:Boolean): Completable =
store.update(ArticleEntity::class) store.update(ArticleEntity::class)
.set(ArticleEntity.ANNOUNCE,"") .set(ArticleEntity.READ,state)
.where(ArticleEntity.ID.eq(id)) .where(ArticleEntity.ID.eq(id))
.get() .get()
.single() .single()
.ignoreElement() .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 ...@@ -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.DealModel
import com.biganto.visual.roompark.domain.model.EstateModel import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -27,4 +28,5 @@ interface DealContract{ ...@@ -27,4 +28,5 @@ interface DealContract{
fun getDeals(): Observable<List<DealModel>> fun getDeals(): Observable<List<DealModel>>
fun fetchEstate(building: Int, number: Int): Observable<EstateModel> 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( ...@@ -17,6 +17,7 @@ data class DealPreviewModel(
val dealTourIds : List<Int?>?, val dealTourIds : List<Int?>?,
val isViewed: Boolean = true, val isViewed: Boolean = true,
val tourPreview: String?, val tourPreview: String?,
val isRead: Boolean,
val statusList : List<StatusModel> val statusList : List<StatusModel>
){ ){
constructor(data:Pair<DealModel,List<StatusModel>>) : this( constructor(data:Pair<DealModel,List<StatusModel>>) : this(
...@@ -36,6 +37,7 @@ data class DealPreviewModel( ...@@ -36,6 +37,7 @@ data class DealPreviewModel(
arrayListOf<Int?>(data.first.estate.multitourId), arrayListOf<Int?>(data.first.estate.multitourId),
false, false,
data.first.estate.multitourPreview, data.first.estate.multitourPreview,
data.first.isRead,
data.second data.second
) )
} }
......
...@@ -30,6 +30,7 @@ data class DealModel( ...@@ -30,6 +30,7 @@ data class DealModel(
val amount_pay_sum:Int, val amount_pay_sum:Int,
val statusId:Int, val statusId:Int,
val managerName: String, val managerName: String,
val isRead: Boolean,
val estate:EstateModel val estate:EstateModel
) )
...@@ -41,6 +42,7 @@ fun fromEntity(entity:DealEntity) = DealModel( ...@@ -41,6 +42,7 @@ fun fromEntity(entity:DealEntity) = DealModel(
amount_pay_sum = entity.amountPaySum, amount_pay_sum = entity.amountPaySum,
statusId = entity.statusId, statusId = entity.statusId,
managerName = entity.managerName, managerName = entity.managerName,
isRead = entity.read,
estate = fromEntity(entity.estate as EstateEntity) estate = fromEntity(entity.estate as EstateEntity)
) )
......
...@@ -13,5 +13,7 @@ class DealseUseCase @Inject constructor( ...@@ -13,5 +13,7 @@ class DealseUseCase @Inject constructor(
fun getDeals() = contract.getDeals() 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 ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.article
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.ArticleInteractor import com.biganto.visual.roompark.domain.interactor.ArticleInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
...@@ -29,8 +30,7 @@ class ArticleScreenPresenter @Inject constructor( ...@@ -29,8 +30,7 @@ class ArticleScreenPresenter @Inject constructor(
.map { ArticleScreenViewState.ArticleLoaded(it) } .map { ArticleScreenViewState.ArticleLoaded(it) }
val setRead = interactor.setArticleRead(selectedArticleId) val setRead = interactor.setArticleRead(selectedArticleId)
.andThen({ ArticleScreenViewState.Idle()}) .andThen(Observable.just(ArticleScreenViewState.Idle()))
val state = restoreStateObservable val state = restoreStateObservable
......
...@@ -4,11 +4,11 @@ import android.content.Context ...@@ -4,11 +4,11 @@ import android.content.Context
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.DealInteractor 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.DealModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.InfoShowType import com.biganto.visual.roompark.presentation.screen.estate.InfoShowType
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
...@@ -22,7 +22,6 @@ import javax.inject.Named ...@@ -22,7 +22,6 @@ import javax.inject.Named
class DealScreenPresenter @Inject constructor( class DealScreenPresenter @Inject constructor(
private val interactor: DealInteractor, private val interactor: DealInteractor,
private val interactor2: EstateInteractor,
private val context: Context, private val context: Context,
@Named(SELECTED_DEAL_ID_KEY) private val dealId:String @Named(SELECTED_DEAL_ID_KEY) private val dealId:String
) )
...@@ -45,8 +44,13 @@ class DealScreenPresenter @Inject constructor( ...@@ -45,8 +44,13 @@ class DealScreenPresenter @Inject constructor(
DealScreenViewState.LoadDeal(deal ,interactor.getStatusListSync()) DealScreenViewState.LoadDeal(deal ,interactor.getStatusListSync())
} }
val setRead = interactor.setDealRead(dealId)
.andThen(Observable.just(DealScreenViewState.Idle()))
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(fetchDeal) .mergeWith(fetchDeal)
.mergeWith(setRead)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.domain.model.StatusModel ...@@ -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.domain.model.typeDoubleString
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter 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.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.extensions.toRubly
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
...@@ -68,10 +69,15 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -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.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 onStartFlatObs: Observable<Int?> get() = startFlat.clicks().map { bindedModel.estateId }
val onStartTourObs: Observable<Int?> get() = startTour.clicks().map { bindedModel.tourId } val onStartTourObs: Observable<Int?> get() = startTour.clicks().map { bindedModel.tourId }
override fun onViewBound(model: DealPreviewModel) { override fun onViewBound(model: DealPreviewModel) {
dealReadFlag.setGone(model.isRead)
estateTitle.text = estateTitle.text =
itemView.context.resources?.getString(model.type.typeDoubleString(),model.name) itemView.context.resources?.getString(model.type.typeDoubleString(),model.name)
renderCommonInfo(model) renderCommonInfo(model)
...@@ -93,6 +99,8 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -93,6 +99,8 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout.invalidate() statusLayout.invalidate()
model.tourPreview?.let { model.tourPreview?.let {
Glide.with(tourScreen) Glide.with(tourScreen)
.load(it) .load(it)
......
...@@ -4,26 +4,25 @@ ...@@ -4,26 +4,25 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="4dp"
> >
<FrameLayout <FrameLayout
android:elevation="10dp" android:elevation="10dp"
android:id="@+id/feed_read" android:id="@+id/deal_read"
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="12dp" android:layout_height="12dp"
android:background="@drawable/new_feed_icon" android:background="@drawable/new_feed_icon"
android:backgroundTint="@color/colorAccent" android:backgroundTint="@color/colorAccent"
android:visibility="visible" android:visibility="visible"
android:layout_margin="2dp"/> android:layout_margin="6dp"/>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="12dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:orientation="vertical" android:orientation="vertical"
app:cardElevation="6dp" 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