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

restoreObservable should be on detachView neither than on attachView method

parent e1987e37
......@@ -66,6 +66,8 @@ class RoomParkMainActivity(
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState)
router.setRoot(RouterTransaction.with(SplashScreenController()))
headerToolbarBack.setOnClickListener {onBackPressed()}
}
override fun displayBackButton(show: Boolean) {
......@@ -89,6 +91,7 @@ class RoomParkMainActivity(
override val headerToolbarBack
get() = headerToolbar.findViewById<MaterialTextView>(R.id.back_button_chevron)
override fun setToolbar(header:HeaderToolbarModel?,status:StatusToolbarModel?){
appBar.setExpanded(false,false)
if (header == null && status == null){
......
......@@ -16,6 +16,7 @@ class ArticleInteractor @Inject constructor(
fun fetchArticle(articleId: Int): Observable<ArticleModel> =
uc.getArticle(articleId)
// Single.just(
// when (articleId) {
// 2 -> article2
......
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import io.reactivex.Single
import com.biganto.visual.roompark.domain.use_case.FeedUseCase
import javax.inject.Inject
/**
......@@ -9,16 +8,11 @@ import javax.inject.Inject
*/
class ArticlesInteractor @Inject constructor(
private val uc: FeedUseCase
) {
fun fetchArticles(feedAlias: String): Single<ArticlesPreviewModel> = Single.just(
when (feedAlias) {
"news" -> FeedsInteractor.testNewsArticles
"blog" -> FeedsInteractor.testBlogsArticles
"constructors_blog" -> FeedsInteractor.testDevArticles
else -> error("unknown feedId")
}
)
fun fetchArticles(feed:String) =
uc.getArticles(feed)
}
......
......@@ -132,15 +132,6 @@ class DealScreenController :
)
}
)
toolBar.headerToolbarBack?.let {
detachDisposable.add(
it.clicks()
.doOnNext { Timber.d("clicked: 1") }
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe { handleBack() }
)
}
}
private fun setToolbar(){
......
package com.biganto.visual.roompark.presentation.screen.feed_list
import android.view.View
import android.widget.ProgressBar
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
......@@ -12,8 +13,10 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.presentation.screen.article.ArticleScreenController
import com.biganto.visual.roompark.presentation.screen.feed_list.util.ArticlesAdapter
import com.biganto.visual.roompark.util.extensions.setGone
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.textview.MaterialTextView
import timber.log.Timber
import javax.inject.Inject
......@@ -44,6 +47,12 @@ class ArticlesScreenController :
@BindView(R.id.articles_recycler_view)
lateinit var articlesRecyclerView: RecyclerView
@BindView(R.id.progress_bar_view)
lateinit var progressBar: ProgressBar
@BindView(R.id.empty_list_text_view)
lateinit var emptyListNotice: MaterialTextView
private fun setToolbar() {
articlesRecyclerView.isNestedScrollingEnabled = false
......@@ -102,14 +111,32 @@ class ArticlesScreenController :
}
private fun render(viewState: ArticlesScreenViewState.Idle){
progressBar.setGone(false)
emptyListNotice.setGone(true)
articlesRecyclerView.setGone(true)
}
private fun render(viewState: ArticlesScreenViewState.SomeError) =
private fun render(viewState: ArticlesScreenViewState.SomeError) {
showError(viewState.exception)
progressBar.setGone(true)
}
private fun render(viewState: ArticlesScreenViewState.ArticlesLoaded) {
(articlesRecyclerView.adapter as ArticlesAdapter).setItems(viewState.items)
progressBar.setGone(true)
emptyListNotice.setGone(true)
articlesRecyclerView.setGone(true)
if (viewState.items.isNullOrEmpty())
{
emptyListNotice.setGone(false)
articlesRecyclerView.setGone(true)
}
else{
emptyListNotice.setGone(true)
articlesRecyclerView.setGone(false)
(articlesRecyclerView.adapter as ArticlesAdapter).setItems(viewState.items)
}
}
private fun getComponent() = DaggerArticlesScreenComponent.factory()
......
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.feed_list
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.ArticlesInteractor
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
......@@ -27,7 +28,8 @@ class ArticlesScreenPresenter @Inject constructor(
Timber.d("feedId : $feedId")
val prefetchCards = interactor.fetchArticles(feedId)
.map { ArticlesScreenViewState.ArticlesLoaded(it.articles) }
.map<ArticlesScreenViewState>{ ArticlesScreenViewState.ArticlesLoaded(it.articles) }
.startWith(Observable.just<ArticlesScreenViewState>(ArticlesScreenViewState.Idle()))
val state = restoreStateObservable
.mergeWith(prefetchCards)
......
......@@ -47,24 +47,22 @@ class FeedsScreenController :
override fun onCameraSelected(): Observable<WebCamModel> =
(camsRecyclerView.adapter as CamsListAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.debounce (1220L, TimeUnit.MILLISECONDS)
override fun onArticleSelected(): Observable<ArticlePreviewModel> =
(feedsRecyclerView.adapter as ArticlesPreviewAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.debounce (1220L, TimeUnit.MILLISECONDS)
override fun onAlbumSelected(): Observable<AlbumPreviewModel> =
(devProgressRecyclerView.adapter as AlbumsPreviewAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.debounce (1220L, TimeUnit.MILLISECONDS)
override fun feedsTabSelected(): Observable<String>
= feedsTabs.selections()
.filter { it.position>= 0 && it.position<storedFeedsList.size }
.debounce (200L, TimeUnit.MILLISECONDS)
.doOnNext { Timber.d("it.position ${it.position}") }
.map { it.position }
.map { storedFeedsList[it].alias }
.observeOn(AndroidSchedulers.mainThread())
......@@ -146,7 +144,7 @@ class FeedsScreenController :
}
override fun render(viewState: FeedsScreenViewState) {
super.render(viewState)
// super.render(viewState)
Timber.d("Render state $viewState")
when(viewState){
is FeedsScreenViewState.Idle -> render(viewState)
......
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.feeds
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.FeedsInteractor
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
......@@ -32,10 +33,15 @@ class FeedsScreenPresenter @Inject constructor(
override fun attachView(view: FeedsScreen) {
Timber.d("AttachView ")
restoreStateObservable.accept(FeedsScreenViewState.RestoreView(restoreModel))
super.attachView(view)
}
override fun detachView() {
super.detachView()
restoreStateObservable.accept(FeedsScreenViewState.RestoreView(restoreModel))
}
override fun bindIntents() {
val fetchCams = interactor.fetchCams()
......@@ -69,10 +75,8 @@ class FeedsScreenPresenter @Inject constructor(
.onErrorReturn (::parseError)
val switchToAllArtiles = intent(FeedsScreen::onAllFeedArticles)
.map<FeedsScreenViewState> {
FeedsScreenViewState.ToArticlesScreen(it.alias)
}
.onErrorReturn (::parseError)
.flatMap{ Observable.defer{Observable.just<FeedsScreenViewState>(
FeedsScreenViewState.ToArticlesScreen(it.alias)) }}
val selectCamera = intent(FeedsScreen::onCameraSelected)
.map<FeedsScreenViewState> {
......@@ -99,8 +103,9 @@ class FeedsScreenPresenter @Inject constructor(
}
.onErrorReturn (::parseError)
val state = restoreStateObservable
.mergeWith(fetchFeeds)
val state =
fetchFeeds
.mergeWith(getFeedArticlesPreview)
.mergeWith(fetchAlbums)
.mergeWith(fetchCams)
......@@ -109,6 +114,7 @@ class FeedsScreenPresenter @Inject constructor(
.mergeWith(selectCamera)
.mergeWith(selectAlbum)
.mergeWith(selectArticle)
.mergeWith(restoreStateObservable)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -4,6 +4,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:fillColor="@color/colorAccent"
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
</vector>
......@@ -6,6 +6,22 @@
android:background="@color/colorNoticeBackground"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar_view"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/empty_list_text_view"
style="@style/Common_Text.Notice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Нет элементов"
android:textAlignment="center" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/articles_recycler_view"
android:layout_width="match_parent"
......
......@@ -14,7 +14,6 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@color/colorAccentSecondary"
app:image_corner_radius="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/feed_title_info_text_view"
......
......@@ -18,7 +18,6 @@
android:gravity="start|center_vertical"
android:text="МОИ \nСДЕЛКИ"
android:textAlignment="gravity"
app:drawableTint="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -34,7 +33,6 @@
android:fitsSystemWindows="true"
android:gravity="start|center_vertical"
android:includeFontPadding="true"
android:text="Ffff"
android:textAlignment="gravity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/include13"
......
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