Commit 00df4a29 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix read flag (remove hardcoded value)

parent e3619ad6
......@@ -55,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())
......@@ -66,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)
......@@ -123,7 +121,7 @@ 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)
......
......@@ -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
)
......
......@@ -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())
......
......@@ -69,7 +69,7 @@ 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
@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 }
......
......@@ -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)
......
......@@ -35,7 +35,8 @@
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"
......
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