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