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( ...@@ -55,7 +55,6 @@ class FeedsContractModule @Inject constructor(
.doOnNext { Timber.d("raw0 $it") } .doOnNext { Timber.d("raw0 $it") }
.map { it.items } .map { it.items }
.map { fromRaw(it, feedAlias) } .map { fromRaw(it, feedAlias) }
.doOnNext { Timber.d("raw enitites $it") }
.doOnNext(db::blockingUpsert) .doOnNext(db::blockingUpsert)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
...@@ -66,7 +65,6 @@ class FeedsContractModule @Inject constructor( ...@@ -66,7 +65,6 @@ class FeedsContractModule @Inject constructor(
db.fetchArticles(feedAlias, pageSize, startIndex) db.fetchArticles(feedAlias, pageSize, startIndex)
.toList() .toList()
.toObservable() .toObservable()
.doOnNext { Timber.d("db items: ${it.size}") }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
private fun fetchArticles(feedAlias: String,pageSize:Int = 10, startIndex:Int = 0) private fun fetchArticles(feedAlias: String,pageSize:Int = 10, startIndex:Int = 0)
...@@ -123,7 +121,7 @@ class FeedsContractModule @Inject constructor( ...@@ -123,7 +121,7 @@ class FeedsContractModule @Inject constructor(
private fun fetchArticle(articleId:Int): Observable<ArticleModel> = private fun fetchArticle(articleId:Int): Observable<ArticleModel> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchArticleDb(articleId),fetchArticleApi(articleId)) arrayListOf(fetchArticleDb(articleId),fetchArticleApi(articleId))
).map { fromEntity(it,true) } ).map { fromEntity(it) }
override fun articleRead(articleId: Int): Completable = override fun articleRead(articleId: Int): Completable =
db.setArticleReadState(articleId,true) db.setArticleReadState(articleId,true)
......
...@@ -48,22 +48,22 @@ fun fromEntity(entity: FeedEntity):FeedModel = FeedModel( ...@@ -48,22 +48,22 @@ fun fromEntity(entity: FeedEntity):FeedModel = FeedModel(
alias = entity.alias alias = entity.alias
) )
fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel( fun fromEntityPreview(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
articleId = entity.id, articleId = entity.id,
published = entity.published, published = entity.published,
title = entity.title, title = entity.title,
announce = entity.announce?:"", announce = entity.announce?:"",
previewUrl = entity.preview?:"", previewUrl = entity.preview?:"",
isRead = false isRead = entity.read
) )
fun fromEntity(parentId:String,entity: List<ArticleEntity>):ArticlesPreviewModel = fun fromEntity(parentId:String,entity: List<ArticleEntity>):ArticlesPreviewModel =
ArticlesPreviewModel( ArticlesPreviewModel(
parentFeedAlias = parentId, parentFeedAlias = parentId,
articles = fromEntity(entity,::fromEntity) articles = fromEntity(entity,::fromEntityPreview)
) )
fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel = fun fromEntity(entity: ArticleEntity) : ArticleModel =
ArticleModel( ArticleModel(
articleId = entity.id, articleId = entity.id,
published = entity.published, published = entity.published,
...@@ -71,7 +71,7 @@ fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel = ...@@ -71,7 +71,7 @@ fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel =
htmlBody = entity.body!!, htmlBody = entity.body!!,
previewUrl = entity.preview?:DEFAULT_ROOM_PARK_PREVIEW, previewUrl = entity.preview?:DEFAULT_ROOM_PARK_PREVIEW,
bottomPhotoList = entity.photo, bottomPhotoList = entity.photo,
isRead = read isRead = entity.read
) )
......
...@@ -46,7 +46,7 @@ class AuthScreenPresenter @Inject constructor( ...@@ -46,7 +46,7 @@ class AuthScreenPresenter @Inject constructor(
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(onAuth) .mergeWith(onAuth)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.onErrorReturn(::parseError) .onErrorReturn(::parseError)
.subscribeOn(Schedulers.single()) .subscribeOn(Schedulers.single())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -40,6 +40,7 @@ class DealsScreenPresenter @Inject constructor( ...@@ -40,6 +40,7 @@ class DealsScreenPresenter @Inject constructor(
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(fetchDeals) .mergeWith(fetchDeals)
.doOnError{ Timber.e(it)} .doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -69,7 +69,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -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.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 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 }
......
...@@ -29,6 +29,7 @@ class FavoritesScreenPresenter @Inject constructor( ...@@ -29,6 +29,7 @@ class FavoritesScreenPresenter @Inject constructor(
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(prefetchCards) .mergeWith(prefetchCards)
.doOnError{ Timber.e(it)} .doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -34,6 +34,7 @@ class ArticlesScreenPresenter @Inject constructor( ...@@ -34,6 +34,7 @@ class ArticlesScreenPresenter @Inject constructor(
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(prefetchCards) .mergeWith(prefetchCards)
.doOnError{ Timber.e(it)} .doOnError{ Timber.e(it)}
.onErrorReturn(::parseError)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc ...@@ -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.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone import com.biganto.visual.roompark.util.extensions.setGone
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import timber.log.Timber
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
...@@ -38,6 +39,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>( ...@@ -38,6 +39,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
override fun onViewBound(model: ArticlePreviewModel) { override fun onViewBound(model: ArticlePreviewModel) {
Timber.d("readeed?: ${model.isRead} of ${model.title}")
articleDate.text = dateFormatter.format(model.published) articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title articleTitle.text = model.title
articleIsRead.setGone(model.isRead) articleIsRead.setGone(model.isRead)
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
android:background="@drawable/new_feed_icon" android:background="@drawable/new_feed_icon"
android:visibility="visible" android:visibility="visible"
app:layout_constraintStart_toStartOf="@+id/guideline" app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/feed_date_text_view" 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