Commit ddbb760d authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix miscellaneous

parent 3efb4f3f
......@@ -15,21 +15,17 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.conductor.dialogs.PhotoDialogController
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.presentation.screen.article.util.ArticleBottomPhotoAdapter
import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdapter
import com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import com.biganto.visual.roompark.util.extensions.formatToSimple
import com.biganto.visual.roompark.util.extensions.setGone
import com.bluelinelabs.conductor.RouterTransaction
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.recyclerview.scrollStateChanges
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import jp.wasabeef.glide.transformations.BlurTransformation
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
......@@ -150,6 +146,7 @@ class ArticleScreenController :
articleDate.text = viewState.item.published.formatToSimple
bottomPhotosRecyclerView.setGone(viewState.item.bottomPhotoList.isNullOrEmpty())
viewState.item.bottomPhotoList?.let {
(bottomPhotosRecyclerView.adapter as ArticleBottomPhotoAdapter).setItems(it)
}
......
......@@ -123,6 +123,7 @@ class ArticlesScreenController :
is ArticlesScreenViewState.Idle -> render(viewState)
is ArticlesScreenViewState.ArticlesLoaded -> render(viewState)
is ArticlesScreenViewState.ArticlesScrollPage -> render(viewState)
is ArticlesScreenViewState.RestoreView -> render(viewState)
is ArticlesScreenViewState.SomeError -> render(viewState)
}
}
......@@ -144,6 +145,22 @@ class ArticlesScreenController :
(articlesRecyclerView.adapter as ArticlesAdapter).addItems(viewState.items)
}
private fun render(viewState: ArticlesScreenViewState.RestoreView){
progressBar.setGone(true)
emptyListNotice.setGone(true)
articlesRecyclerView.setGone(true)
if (viewState.restore.articles.isNullOrEmpty())
{
emptyListNotice.setGone(false)
articlesRecyclerView.setGone(true)
}
else{
emptyListNotice.setGone(true)
articlesRecyclerView.setGone(false)
(articlesRecyclerView.adapter as ArticlesAdapter).setItems(viewState.restore.articles)
}
}
private fun render(viewState: ArticlesScreenViewState.ArticlesLoaded) {
......
......@@ -23,6 +23,14 @@ class ArticlesScreenPresenter @Inject constructor(
)
: BigantoBasePresenter<ArticlesScreen, ArticlesScreenViewState>() {
private val restoreModel = RestoreModel(mutableListOf())
override fun detachView() {
super.detachView()
restoreStateObservable.accept(ArticlesScreenViewState.RestoreView(restoreModel))
}
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> ArticlesScreenViewState.SomeError(e)}
......@@ -35,10 +43,13 @@ class ArticlesScreenPresenter @Inject constructor(
val getNewArticlesPage = intent(ArticlesScreen::requsetsNewArticles)
.flatMap { interactor.fetchArticlesPage(feedId, FEED_PAGE_SIZE,it) }
.map<ArticlesScreenViewState> {
// restoreModel.articles = it.articles
Timber.d("arrived list: ${it.articles.size}")
ArticlesScreenViewState.ArticlesScrollPage(it.articles.toList())
.map<ArticlesScreenViewState> {articlePage ->
articlePage.articles
.asSequence()
.filter { !restoreModel.articles.contains(it) }
.toList()
.let {uniqueItems->restoreModel.articles.addAll(uniqueItems)}
ArticlesScreenViewState.ArticlesScrollPage(articlePage.articles.toList())
}
.onErrorReturn (::parseError)
......
......@@ -14,4 +14,10 @@ sealed class ArticlesScreenViewState : BigantoBaseViewState() {
class ArticlesLoaded(val items: List<ArticlePreviewModel>) : ArticlesScreenViewState()
class SomeError(val exception: ExceptionString) : ArticlesScreenViewState()
class ArticlesScrollPage(val items:List<ArticlePreviewModel>) : ArticlesScreenViewState()
class RestoreView(val restore:RestoreModel) : ArticlesScreenViewState()
}
data class RestoreModel(
var articles:MutableList<ArticlePreviewModel>
)
\ No newline at end of file
......@@ -28,7 +28,8 @@ class FeedsScreenPresenter @Inject constructor(
arrayListOf(),
arrayListOf(),
arrayListOf(),
arrayListOf())
mutableListOf()
)
override fun attachView(view: FeedsScreen) {
......@@ -67,9 +68,13 @@ class FeedsScreenPresenter @Inject constructor(
val getFeedArticlesPreview = intent(FeedsScreen::feedsTabSelected)
.flatMap { interactor.fetchArticles(it) }
.map<FeedsScreenViewState> {
restoreModel.articles = it.articles
FeedsScreenViewState.GetFeedArticlesPreview(it.articles.toList())
.map<FeedsScreenViewState> {articlePage ->
articlePage.articles
.asSequence()
.filter { !restoreModel.articles.contains(it) }
.toList()
.let {uniqueItems->restoreModel.articles.addAll(uniqueItems)}
FeedsScreenViewState.GetFeedArticlesPreview(articlePage.articles.toList())
}
.onErrorReturn (::parseError)
......@@ -95,10 +100,14 @@ class FeedsScreenPresenter @Inject constructor(
val getNewArticlesPage = intent(FeedsScreen::requsetsNewArticles)
.flatMap { interactor.fetchArticles(it.first.alias, FEED_PREVIEW_PAGE_SIZE,it.second) }
.map<FeedsScreenViewState> {
restoreModel.articles = it.articles
Timber.d("arrived list: ${it.articles.size}")
FeedsScreenViewState.ArticlesScrollPage(it.articles.toList())
.map<FeedsScreenViewState> {articlePage ->
articlePage.articles
.asSequence()
.filter { !restoreModel.articles.contains(it) }
.toList()
.let {uniqueItems->restoreModel.articles.addAll(uniqueItems)}
FeedsScreenViewState.ArticlesScrollPage(articlePage.articles.toList())
}
.onErrorReturn (::parseError)
......
......@@ -38,5 +38,5 @@ data class RestoreModel(
var feeds:List<FeedModel>,
var albums:List<AlbumPreviewModel>,
var cams:List<WebCamModel>,
var articles:List<ArticlePreviewModel>
var articles:MutableList <ArticlePreviewModel>
)
\ No newline at end of file
......@@ -16,19 +16,17 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/default_image_placeholder" />
app:layout_constraintTop_toTopOf="parent" />
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
android:id="@+id/articlePreview"
app:image_corner_radius="4dp"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_marginStart="16dp"
android:layout_marginTop="44dp"
app:image_corner_radius="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_favorites" />
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/articleDate"
......@@ -37,7 +35,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:includeFontPadding="false"
android:text="22 / 02 / 2019"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
......
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