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