Commit 28a39fa1 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add default error handler to all screens

parent 3de637c8
...@@ -15,6 +15,7 @@ import com.biganto.visual.roompark.base.ICollapsingToolBar ...@@ -15,6 +15,7 @@ import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController
import com.biganto.visual.roompark.di.dagger.ActivityModule import com.biganto.visual.roompark.di.dagger.ActivityModule
import com.biganto.visual.roompark.util.monades.ExceptionString
import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
...@@ -93,6 +94,9 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon ...@@ -93,6 +94,9 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
return super.handleBack() return super.handleBack()
} }
fun showError(e: ExceptionString) =
e.selectHandler(snackbar::showSnackBar,snackbar::showSnackBar)
protected val isTablet protected val isTablet
get() = resources?.getBoolean(R.bool.isTablet)?:false get() = resources?.getBoolean(R.bool.isTablet)?:false
......
...@@ -22,8 +22,10 @@ abstract class BigantoBasePresenter<V : MvpView, VS> ...@@ -22,8 +22,10 @@ abstract class BigantoBasePresenter<V : MvpView, VS>
Observable.defer { Observable.just(parseError(t)) } Observable.defer { Observable.just(parseError(t)) }
abstract fun vsByCode(code: Int): (ExceptionString) -> VS abstract fun defaultErrorViewStateHandler(): (ExceptionString) -> VS
abstract fun vsByThrowable(t: Throwable): (ExceptionString) -> VS
open fun vsByCode(code: Int) = defaultErrorViewStateHandler()
open fun vsByThrowable(t: Throwable) = defaultErrorViewStateHandler()
open fun parseError(t: Throwable): VS = open fun parseError(t: Throwable): VS =
when (t) { when (t) {
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.article ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.article
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.ArticleInteractor import com.biganto.visual.roompark.domain.interactor.ArticleInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
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
...@@ -16,6 +17,8 @@ class ArticleScreenPresenter @Inject constructor( ...@@ -16,6 +17,8 @@ class ArticleScreenPresenter @Inject constructor(
private val interactor: ArticleInteractor private val interactor: ArticleInteractor
) )
: BigantoBasePresenter<ArticleScreen, ArticleScreenViewState>() { : BigantoBasePresenter<ArticleScreen, ArticleScreenViewState>() {
override fun defaultErrorViewStateHandler()=
{e:ExceptionString -> ArticleScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.article ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.article
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.ArticleModel import com.biganto.visual.roompark.domain.model.ArticleModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.ArticleModel ...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.ArticleModel
sealed class ArticleScreenViewState : BigantoBaseViewState() { sealed class ArticleScreenViewState : BigantoBaseViewState() {
class Idle : ArticleScreenViewState() class Idle : ArticleScreenViewState()
class ArticleLoaded(val item: ArticleModel) : ArticleScreenViewState() class ArticleLoaded(val item: ArticleModel) : ArticleScreenViewState()
class SomeError(val error:ExceptionString ) : ArticleScreenViewState()
} }
\ No newline at end of file
...@@ -93,13 +93,12 @@ class AuthScreenController : ...@@ -93,13 +93,12 @@ class AuthScreenController :
} }
private fun render(viewState: AuthScreenViewState.SignInError){ private fun render(viewState: AuthScreenViewState.SignInError){
viewState.exception.selectHandler(snackbar::showSnackBar,snackbar::showSnackBar) showError(viewState.exception)
signInButton.isEnabled=true signInButton.isEnabled=true
} }
private fun render(viewState: AuthScreenViewState.SomeError){ private fun render(viewState: AuthScreenViewState.SomeError) =
viewState.exception.selectHandler(snackbar::showSnackBar,snackbar::showSnackBar) showError(viewState.exception)
}
override fun getLayoutId(): Int = R.layout.authentication_screen override fun getLayoutId(): Int = R.layout.authentication_screen
......
...@@ -18,15 +18,15 @@ class AuthScreenPresenter @Inject constructor( ...@@ -18,15 +18,15 @@ class AuthScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<AuthScreen, AuthScreenViewState>() { : BigantoBasePresenter<AuthScreen, AuthScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e:ExceptionString -> AuthScreenViewState.SomeError(e)}
override fun vsByCode(code: Int): (ExceptionString) -> AuthScreenViewState = override fun vsByCode(code: Int): (ExceptionString) -> AuthScreenViewState =
when (code) { when (code) {
101 -> {e:ExceptionString -> AuthScreenViewState.SignInError(e)} 101 -> {e:ExceptionString -> AuthScreenViewState.SignInError(e)}
else -> {e:ExceptionString -> AuthScreenViewState.SomeError(e)} else -> {e:ExceptionString -> AuthScreenViewState.SomeError(e)}
} }
override fun vsByThrowable(t: Throwable): (ExceptionString) -> AuthScreenViewState =
{e:ExceptionString -> AuthScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
val onAuth = intent(AuthScreen::tryAuth) val onAuth = intent(AuthScreen::tryAuth)
......
...@@ -69,6 +69,7 @@ class DealsScreenController : ...@@ -69,6 +69,7 @@ class DealsScreenController :
when(viewState){ when(viewState){
is DealsScreenViewState.Idle -> render(viewState) is DealsScreenViewState.Idle -> render(viewState)
is DealsScreenViewState.DealsLoaded -> render(viewState) is DealsScreenViewState.DealsLoaded -> render(viewState)
is DealsScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -76,12 +77,13 @@ class DealsScreenController : ...@@ -76,12 +77,13 @@ class DealsScreenController :
} }
private fun render(viewState: DealsScreenViewState.DealsLoaded){ private fun render(viewState: DealsScreenViewState.DealsLoaded){
(favoritesRecyclerView.adapter as DealsListAdapter).addItems(viewState.items) (favoritesRecyclerView.adapter as DealsListAdapter).addItems(viewState.items)
} }
private fun render(viewState: DealsScreenViewState.SomeError) =
showError(viewState.exception)
private fun getComponent() = DaggerDealsScreenComponent.factory() private fun getComponent() = DaggerDealsScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity) .create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this) .inject(this)
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.deals ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.deals
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.DealsInteractor import com.biganto.visual.roompark.domain.interactor.DealsInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
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
...@@ -17,6 +18,8 @@ class DealsScreenPresenter @Inject constructor( ...@@ -17,6 +18,8 @@ class DealsScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<DealsScreen, DealsScreenViewState>() { : BigantoBasePresenter<DealsScreen, DealsScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e:ExceptionString -> DealsScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
......
package com.biganto.visual.roompark.presentation.screen.deals package com.biganto.visual.roompark.presentation.screen.deals
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -10,5 +11,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState ...@@ -10,5 +11,6 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed class DealsScreenViewState : BigantoBaseViewState() { sealed class DealsScreenViewState : BigantoBaseViewState() {
class Idle : DealsScreenViewState() class Idle : DealsScreenViewState()
class DealsLoaded(val items:List<DealPreviewModel>) : DealsScreenViewState() class DealsLoaded(val items:List<DealPreviewModel>) : DealsScreenViewState()
class SomeError(val exception: ExceptionString) : DealsScreenViewState()
} }
...@@ -70,6 +70,7 @@ class FavoritesScreenController : ...@@ -70,6 +70,7 @@ class FavoritesScreenController :
when(viewState){ when(viewState){
is FavoritesScreenViewState.Idle -> render(viewState) is FavoritesScreenViewState.Idle -> render(viewState)
is FavoritesScreenViewState.FavoriteEstatesLoaded -> render(viewState) is FavoritesScreenViewState.FavoriteEstatesLoaded -> render(viewState)
is FavoritesScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -77,6 +78,9 @@ class FavoritesScreenController : ...@@ -77,6 +78,9 @@ class FavoritesScreenController :
} }
private fun render(viewState: FavoritesScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: FavoritesScreenViewState.FavoriteEstatesLoaded) { private fun render(viewState: FavoritesScreenViewState.FavoriteEstatesLoaded) {
(favoritesRecyclerView.adapter as FavoritesListAdapter).addItems(viewState.items) (favoritesRecyclerView.adapter as FavoritesListAdapter).addItems(viewState.items)
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.FavoritesInteractor import com.biganto.visual.roompark.domain.interactor.FavoritesInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
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
...@@ -17,6 +18,8 @@ class FavoritesScreenPresenter @Inject constructor( ...@@ -17,6 +18,8 @@ class FavoritesScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<FavoritesScreen, FavoritesScreenViewState>() { : BigantoBasePresenter<FavoritesScreen, FavoritesScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> FavoritesScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.EstateModel import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.EstateModel ...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.EstateModel
sealed class FavoritesScreenViewState : BigantoBaseViewState() { sealed class FavoritesScreenViewState : BigantoBaseViewState() {
class Idle : FavoritesScreenViewState() class Idle : FavoritesScreenViewState()
class FavoriteEstatesLoaded(val items: List<EstateModel>) : FavoritesScreenViewState() class FavoriteEstatesLoaded(val items: List<EstateModel>) : FavoritesScreenViewState()
class SomeError(val exception: ExceptionString) : FavoritesScreenViewState()
} }
\ No newline at end of file
...@@ -86,6 +86,7 @@ class ArticlesScreenController : ...@@ -86,6 +86,7 @@ class ArticlesScreenController :
when(viewState){ when(viewState){
is ArticlesScreenViewState.Idle -> render(viewState) is ArticlesScreenViewState.Idle -> render(viewState)
is ArticlesScreenViewState.ArticlesLoaded -> render(viewState) is ArticlesScreenViewState.ArticlesLoaded -> render(viewState)
is ArticlesScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -93,6 +94,8 @@ class ArticlesScreenController : ...@@ -93,6 +94,8 @@ class ArticlesScreenController :
} }
private fun render(viewState: ArticlesScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: ArticlesScreenViewState.ArticlesLoaded) { private fun render(viewState: ArticlesScreenViewState.ArticlesLoaded) {
(articlesRecyclerView.adapter as ArticlesAdapter).setItems(viewState.items) (articlesRecyclerView.adapter as ArticlesAdapter).setItems(viewState.items)
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.feed_list ...@@ -2,6 +2,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 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
...@@ -19,6 +20,8 @@ class ArticlesScreenPresenter @Inject constructor( ...@@ -19,6 +20,8 @@ class ArticlesScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<ArticlesScreen, ArticlesScreenViewState>() { : BigantoBasePresenter<ArticlesScreen, ArticlesScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> ArticlesScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
Timber.d("feedId : $feedId") Timber.d("feedId : $feedId")
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.feed_list ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.feed_list
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.ArticlePreviewModel import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.ArticlePreviewModel ...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
sealed class ArticlesScreenViewState : BigantoBaseViewState() { sealed class ArticlesScreenViewState : BigantoBaseViewState() {
class Idle : ArticlesScreenViewState() class Idle : ArticlesScreenViewState()
class ArticlesLoaded(val items: List<ArticlePreviewModel>) : ArticlesScreenViewState() class ArticlesLoaded(val items: List<ArticlePreviewModel>) : ArticlesScreenViewState()
class SomeError(val exception: ExceptionString) : ArticlesScreenViewState()
} }
\ No newline at end of file
...@@ -123,6 +123,7 @@ class FeedsScreenController : ...@@ -123,6 +123,7 @@ class FeedsScreenController :
is FeedsScreenViewState.CamsList -> render(viewState) is FeedsScreenViewState.CamsList -> render(viewState)
is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState) is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState)
is FeedsScreenViewState.RestoreView -> render(viewState) is FeedsScreenViewState.RestoreView -> render(viewState)
is FeedsScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -130,6 +131,9 @@ class FeedsScreenController : ...@@ -130,6 +131,9 @@ class FeedsScreenController :
} }
private fun render(viewState: FeedsScreenViewState.SomeError) =
showError(viewState.exception)
private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ" private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ"
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.feeds ...@@ -2,6 +2,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 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
...@@ -17,6 +18,10 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -17,6 +18,10 @@ class FeedsScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<FeedsScreen, FeedsScreenViewState>() { : BigantoBasePresenter<FeedsScreen, FeedsScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> FeedsScreenViewState.SomeError(e)}
private val restoreModel = RestoreModel( private val restoreModel = RestoreModel(
arrayListOf(), arrayListOf(),
arrayListOf(), arrayListOf(),
......
...@@ -5,6 +5,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel ...@@ -5,6 +5,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.domain.model.ArticlePreviewModel import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.domain.model.WebCamModel import com.biganto.visual.roompark.domain.model.WebCamModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -20,6 +21,8 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() { ...@@ -20,6 +21,8 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
class GetFeedArticlesPreview(val items:List<ArticlePreviewModel>) : FeedsScreenViewState() class GetFeedArticlesPreview(val items:List<ArticlePreviewModel>) : FeedsScreenViewState()
class RestoreView(val restore:RestoreModel) : FeedsScreenViewState() class RestoreView(val restore:RestoreModel) : FeedsScreenViewState()
class SomeError(val exception: ExceptionString) : FeedsScreenViewState()
} }
data class RestoreModel( data class RestoreModel(
......
package com.biganto.visual.roompark.presentation.screen.home package com.biganto.visual.roompark.presentation.screen.home
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.util.monades.ExceptionString
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -13,6 +14,9 @@ class HomeScreenPresenter @Inject constructor( ...@@ -13,6 +14,9 @@ class HomeScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<HomeScreen, HomeScreenViewState>() { : BigantoBasePresenter<HomeScreen, HomeScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> HomeScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
val state = restoreStateObservable val state = restoreStateObservable
subscribeViewState(state.cast(HomeScreenViewState::class.java), HomeScreen::render) subscribeViewState(state.cast(HomeScreenViewState::class.java), HomeScreen::render)
......
package com.biganto.visual.roompark.presentation.screen.home package com.biganto.visual.roompark.presentation.screen.home
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -10,4 +11,5 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState ...@@ -10,4 +11,5 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed class HomeScreenViewState : BigantoBaseViewState() { sealed class HomeScreenViewState : BigantoBaseViewState() {
class Idle : HomeScreenViewState() class Idle : HomeScreenViewState()
class ToScreen(val message:String) : HomeScreenViewState() class ToScreen(val message:String) : HomeScreenViewState()
class SomeError(val exception: ExceptionString) : HomeScreenViewState()
} }
\ No newline at end of file
...@@ -68,6 +68,7 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -68,6 +68,7 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
when(viewState){ when(viewState){
is HomeScreenViewState.Idle -> render(viewState) is HomeScreenViewState.Idle -> render(viewState)
is HomeScreenViewState.ToScreen -> render(viewState) is HomeScreenViewState.ToScreen -> render(viewState)
is HomeScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -75,6 +76,9 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -75,6 +76,9 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
} }
private fun render(viewState: HomeScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: HomeScreenViewState.ToScreen){ private fun render(viewState: HomeScreenViewState.ToScreen){
......
...@@ -93,9 +93,13 @@ class SettingsScreenController : ...@@ -93,9 +93,13 @@ class SettingsScreenController :
when(viewState){ when(viewState){
is SettingsScreenViewState.Idle -> render(viewState) is SettingsScreenViewState.Idle -> render(viewState)
is SettingsScreenViewState.LoadSettingsList -> render(viewState) is SettingsScreenViewState.LoadSettingsList -> render(viewState)
is SettingsScreenViewState.SomeError -> render(viewState)
} }
} }
private fun render(viewState: SettingsScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: SettingsScreenViewState.Idle){ private fun render(viewState: SettingsScreenViewState.Idle){
} }
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.settings ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.settings
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.SettingsInteractor import com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
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
...@@ -17,6 +18,8 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -17,6 +18,8 @@ class SettingsScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<SettingsScreen, SettingsScreenViewState>() { : BigantoBasePresenter<SettingsScreen, SettingsScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> SettingsScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.settings ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.settings
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.SettingsModel import com.biganto.visual.roompark.domain.model.SettingsModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.SettingsModel ...@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.SettingsModel
sealed class SettingsScreenViewState : BigantoBaseViewState() { sealed class SettingsScreenViewState : BigantoBaseViewState() {
class Idle : SettingsScreenViewState() class Idle : SettingsScreenViewState()
class LoadSettingsList(val settings:SettingsModel) : SettingsScreenViewState() class LoadSettingsList(val settings:SettingsModel) : SettingsScreenViewState()
class SomeError(val exception: ExceptionString) : SettingsScreenViewState()
} }
\ No newline at end of file
...@@ -2,7 +2,6 @@ package com.biganto.visual.roompark.presentation.screen.splash ...@@ -2,7 +2,6 @@ package com.biganto.visual.roompark.presentation.screen.splash
import android.view.View import android.view.View
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
...@@ -53,6 +52,7 @@ class SplashScreenController : ...@@ -53,6 +52,7 @@ class SplashScreenController :
is SplashScreenViewState.Idle -> render(viewState) is SplashScreenViewState.Idle -> render(viewState)
is SplashScreenViewState.ToAuthScreen -> render(viewState) is SplashScreenViewState.ToAuthScreen -> render(viewState)
is SplashScreenViewState.ToHomeScreen -> render(viewState) is SplashScreenViewState.ToHomeScreen -> render(viewState)
is SplashScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -60,6 +60,9 @@ class SplashScreenController : ...@@ -60,6 +60,9 @@ class SplashScreenController :
} }
private fun render(viewState: SplashScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: SplashScreenViewState.ToAuthScreen){ private fun render(viewState: SplashScreenViewState.ToAuthScreen){
router.pushController(RouterTransaction.with(AuthScreenController()) router.pushController(RouterTransaction.with(AuthScreenController())
.popChangeHandler(FadeChangeHandler()) .popChangeHandler(FadeChangeHandler())
......
...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.splash ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.SplashInteractor import com.biganto.visual.roompark.domain.interactor.SplashInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -17,6 +18,9 @@ class SplashScreenPresenter @Inject constructor( ...@@ -17,6 +18,9 @@ class SplashScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<SplashScreen, SplashScreenViewState>() { : BigantoBasePresenter<SplashScreen, SplashScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> SplashScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
val state = restoreStateObservable val state = restoreStateObservable
......
package com.biganto.visual.roompark.presentation.screen.splash package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -11,4 +12,5 @@ sealed class SplashScreenViewState : BigantoBaseViewState() { ...@@ -11,4 +12,5 @@ sealed class SplashScreenViewState : BigantoBaseViewState() {
class Idle : SplashScreenViewState() class Idle : SplashScreenViewState()
class ToHomeScreen() : SplashScreenViewState() class ToHomeScreen() : SplashScreenViewState()
class ToAuthScreen() : SplashScreenViewState() class ToAuthScreen() : SplashScreenViewState()
class SomeError(val exception: ExceptionString) : SplashScreenViewState()
} }
\ No newline at end of file
...@@ -101,9 +101,13 @@ class FindFlatScreenController : ...@@ -101,9 +101,13 @@ class FindFlatScreenController :
Timber.d("Render state $viewState") Timber.d("Render state $viewState")
when(viewState){ when(viewState){
is FindFlatScreenViewState.Idle -> render(viewState) is FindFlatScreenViewState.Idle -> render(viewState)
is FindFlatScreenViewState.StartTour -> render(viewState)
} }
} }
private fun render(viewState: FindFlatScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: FindFlatScreenViewState.Idle){ private fun render(viewState: FindFlatScreenViewState.Idle){
} }
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.to_flat ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.FindFlatInteractor import com.biganto.visual.roompark.domain.interactor.FindFlatInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable 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
...@@ -18,6 +19,9 @@ class FindFlatScreenPresenter @Inject constructor( ...@@ -18,6 +19,9 @@ class FindFlatScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<FindFlatScreen, FindFlatScreenViewState>() { : BigantoBasePresenter<FindFlatScreen, FindFlatScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> FindFlatScreenViewState.SomeError(e)}
override fun bindIntents() { override fun bindIntents() {
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.to_flat ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.TourModel import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
...@@ -14,4 +15,5 @@ sealed class FindFlatScreenViewState : BigantoBaseViewState() { ...@@ -14,4 +15,5 @@ sealed class FindFlatScreenViewState : BigantoBaseViewState() {
class TourFounded(val items:List<TourModel>) : FindFlatScreenViewState() class TourFounded(val items:List<TourModel>) : FindFlatScreenViewState()
class StartTour(val tourId:String) : FindFlatScreenViewState() class StartTour(val tourId:String) : FindFlatScreenViewState()
class FlatNotFound() : FindFlatScreenViewState() class FlatNotFound() : FindFlatScreenViewState()
class SomeError(val exception: ExceptionString) : FindFlatScreenViewState()
} }
\ No newline at end of file
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