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

Merge branch 'feature/read_flag' into develop

parents 68531f19 e310dd12
......@@ -4,6 +4,7 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
......
......@@ -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)=
......
......@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.domain.model.ArticleModel
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
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
......@@ -33,6 +34,7 @@ class FeedsContractModule @Inject constructor(
override fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel> =
fetchArticles(feedAlias)
override fun fetchFeedObservable(feedAlias: String,pageSize:Int, startIndex:Int)
: Observable<ArticlesPreviewModel> = fetchArticles(feedAlias,pageSize,startIndex)
......@@ -53,7 +55,6 @@ class FeedsContractModule @Inject constructor(
.doOnNext { Timber.d("raw0 $it") }
.map { it.items }
.map { fromRaw(it, feedAlias) }
.doOnNext { Timber.d("raw enitites $it") }
.doOnNext(db::blockingUpsert)
.subscribeOn(Schedulers.io())
......@@ -64,7 +65,6 @@ class FeedsContractModule @Inject constructor(
db.fetchArticles(feedAlias, pageSize, startIndex)
.toList()
.toObservable()
.doOnNext { Timber.d("db items: ${it.size}") }
.subscribeOn(Schedulers.io())
private fun fetchArticles(feedAlias: String,pageSize:Int = 10, startIndex:Int = 0)
......@@ -121,7 +121,11 @@ class FeedsContractModule @Inject constructor(
private fun fetchArticle(articleId:Int): Observable<ArticleModel> =
Observable.mergeDelayError(
arrayListOf(fetchArticleDb(articleId),fetchArticleApi(articleId))
).map { fromEntity(it,true) }
).map { fromEntity(it) }
override fun articleRead(articleId: Int): Completable =
db.setArticleReadState(articleId,true)
}
package com.biganto.visual.roompark.data.repository.db
import com.biganto.visual.roompark.data.repository.db.requrey.model.*
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.Single
import io.requery.Persistable
......@@ -31,4 +32,6 @@ interface IDb {
fun getEstate(estateId: Int): Observable<EstateEntity>
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
......@@ -157,4 +158,21 @@ class RequeryRepository @Inject constructor(
.where(EstateEntity.USER_ID.eq(uuid))
.and(EstateEntity.FAVORITE.eq(true))
.get().observable()
override fun setArticleReadState(id:Int,state:Boolean): Completable =
store.update(ArticleEntity::class)
.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()
}
......@@ -27,4 +27,7 @@ interface Article : Persistable {
val feed : Feed?
@get:Convert(TitledPhotoListConverter::class)
var photo : List<TitledPhoto>?
val read : Boolean
}
\ No newline at end of file
......@@ -25,4 +25,6 @@ interface Deal : Persistable {
@get:ForeignKey(references = User::class )
@get:ManyToOne(cascade = [CascadeAction.NONE])
var user:User?
val read : Boolean
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
const val FILES_CACHE_LIMIT_SIZE = 10000
const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L
const val DATABASE_VERSION = 10
const val DATABASE_VERSION = 11
@Module
abstract class AppModule{
......
......@@ -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
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.domain.model.ArticleModel
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
import io.reactivex.Completable
import io.reactivex.Observable
/**
......@@ -20,4 +21,5 @@ interface FeedsContract{
): Observable<ArticlesPreviewModel>
fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel>
fun articleRead(articleId:Int):Completable
}
\ No newline at end of file
......@@ -17,6 +17,8 @@ class ArticleInteractor @Inject constructor(
fun fetchArticle(articleId: Int): Observable<ArticleModel> =
uc.getArticle(articleId)
fun setArticleRead(articleId: Int) = uc.setRead(articleId)
// Single.just(
// when (articleId) {
// 2 -> article2
......
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.domain.use_case.DealseUseCase
import io.reactivex.Observable
import timber.log.Timber
......@@ -23,10 +24,9 @@ class DealInteractor @Inject constructor(
fun getStatusListSync() = statusList.asSequence().sortedBy{ it.orderId }.toList()
fun getFakeDeal(): Observable<DealModel> = Observable.just(dealParkign)
companion object{
fun setDealRead(id:String) = useCase.setDealRead(id)
companion object {
val statusList = arrayListOf<StatusModel>(
StatusModel(
......@@ -86,239 +86,5 @@ 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
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.domain.use_case.DealseUseCase
import io.reactivex.Observable
import javax.inject.Inject
......@@ -19,7 +19,6 @@ class DealsInteractor @Inject constructor(
companion object{
val statusList = arrayListOf<StatusModel>(
StatusModel(
1,
......@@ -77,239 +76,5 @@ class DealsInteractor @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 = "1425",
id = "4621213",
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 = "1231",
id = "42342342",
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)
)
......
......@@ -48,22 +48,22 @@ fun fromEntity(entity: FeedEntity):FeedModel = FeedModel(
alias = entity.alias
)
fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
fun fromEntityPreview(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
articleId = entity.id,
published = entity.published,
title = entity.title,
announce = entity.announce?:"",
previewUrl = entity.preview?:"",
isRead = false
isRead = entity.read
)
fun fromEntity(parentId:String,entity: List<ArticleEntity>):ArticlesPreviewModel =
ArticlesPreviewModel(
parentFeedAlias = parentId,
articles = fromEntity(entity,::fromEntity)
articles = fromEntity(entity,::fromEntityPreview)
)
fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel =
fun fromEntity(entity: ArticleEntity) : ArticleModel =
ArticleModel(
articleId = entity.id,
published = entity.published,
......@@ -71,7 +71,7 @@ fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel =
htmlBody = entity.body!!,
previewUrl = entity.preview?:DEFAULT_ROOM_PARK_PREVIEW,
bottomPhotoList = entity.photo,
isRead = read
isRead = entity.read
)
......
......@@ -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
......@@ -21,4 +21,6 @@ class FeedUseCase @Inject constructor(
fun getArticle(articleId:Int) =
contract.getArticle(articleId)
fun setRead(articleId: Int) = contract.articleRead(articleId)
}
\ 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
......@@ -28,8 +29,13 @@ class ArticleScreenPresenter @Inject constructor(
val prefetchCards = interactor.fetchArticle(selectedArticleId)
.map { ArticleScreenViewState.ArticleLoaded(it) }
val setRead = interactor.setArticleRead(selectedArticleId)
.andThen(Observable.just(ArticleScreenViewState.Idle()))
val state = restoreStateObservable
.mergeWith(prefetchCards)
.mergeWith(setRead)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -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())
......
......@@ -40,6 +40,7 @@ class DealsScreenPresenter @Inject constructor(
val state = restoreStateObservable
.mergeWith(fetchDeals)
.doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.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:View
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)
......
......@@ -29,6 +29,7 @@ class FavoritesScreenPresenter @Inject constructor(
val state = restoreStateObservable
.mergeWith(prefetchCards)
.doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -34,6 +34,7 @@ class ArticlesScreenPresenter @Inject constructor(
val state = restoreStateObservable
.mergeWith(prefetchCards)
.doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.bumptech.glide.Glide
import timber.log.Timber
import java.text.SimpleDateFormat
import java.util.*
......@@ -38,6 +39,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
override fun onViewBound(model: ArticlePreviewModel) {
Timber.d("readeed?: ${model.isRead} of ${model.title}")
articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
articleIsRead.setGone(model.isRead)
......
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_margin="4dp"
>
<FrameLayout
android:elevation="10dp"
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="6dp"/>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
app:cardElevation="6dp"
app:cardMaxElevation="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -240,3 +261,4 @@
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
\ No newline at end of file
......@@ -12,11 +12,9 @@
android:layout_height="128dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:image_corner_radius="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/feed_title_info_text_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -24,31 +22,35 @@
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:orientation="vertical"
app:layout_constraintGuide_begin="160dp" />
app:layout_constraintGuide_begin="150dp" />
<FrameLayout
android:id="@+id/feed_read"
android:layout_width="8dp"
android:layout_width="wrap_content"
android:layout_height="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="18dp"
android:background="@drawable/new_feed_icon"
android:visibility="visible"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/feed_date_text_view"
style="@style/Feed.Notice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:includeFontPadding="false"
android:text="22 / 02 / 2019"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintStart_toEndOf="@+id/feed_read"
app:layout_constraintTop_toTopOf="parent" />
<TextView
......@@ -56,6 +58,7 @@
style="@style/Feed_Title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:includeFontPadding="false"
android:text="В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
......@@ -68,6 +71,7 @@
style="@style/Feed.Description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:includeFontPadding="false"
android:text="В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
......
......@@ -23,12 +23,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="76dp" />
app:layout_constraintGuide_begin="68dp" />
<FrameLayout
android:id="@+id/feed_read"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:background="@drawable/new_feed_icon"
android:visibility="visible"
......@@ -40,13 +41,13 @@
style="@style/Feed.Notice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:includeFontPadding="false"
android:text="22 / 02 / 2019"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintStart_toEndOf="@+id/feed_read"
app:layout_constraintTop_toTopOf="parent" />
<TextView
......@@ -54,6 +55,7 @@
style="@style/Feed_Title"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:includeFontPadding="false"
android:text="В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
......
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