Commit 78caf41a authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

Merge branch 'feature/main_screen' of...

Merge branch 'feature/main_screen' of gitlab.biganto.com:bigantoBogdashkin/room-park-android into feature/main_screen
parents 54b2037a 5d14095e
package com.biganto.visual.roompark.presentation.screen.feeds package com.biganto.visual.roompark.presentation.screen.feeds
import com.biganto.visual.roompark.conductor.BigantoBaseContract import com.biganto.visual.roompark.conductor.BigantoBaseContract
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
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 io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -12,6 +15,9 @@ interface FeedsScreen : BigantoBaseContract<FeedsScreenViewState> { ...@@ -12,6 +15,9 @@ interface FeedsScreen : BigantoBaseContract<FeedsScreenViewState> {
fun feedsTabSelected(): Observable<Int> fun feedsTabSelected(): Observable<Int>
fun requsetsNewArticles(): Observable<Pair<FeedModel, Int>> fun requsetsNewArticles(): Observable<Pair<FeedModel, Int>>
fun onAllFeedArticles(): Observable<FeedModel> fun onAllFeedArticles(): Observable<FeedModel>
fun onCameraSelected(): Observable<WebCamModel>
fun onArticleSelected(): Observable<ArticlePreviewModel>
fun onAlbumSelected(): Observable<AlbumPreviewModel>
} }
......
...@@ -10,7 +10,10 @@ import com.biganto.visual.roompark.R ...@@ -10,7 +10,10 @@ import com.biganto.visual.roompark.R
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
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
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.presentation.screen.feed_list.ArticlesScreenController import com.biganto.visual.roompark.presentation.screen.feed_list.ArticlesScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter
import com.biganto.visual.roompark.presentation.screen.feeds.utils.ArticlesPreviewAdapter import com.biganto.visual.roompark.presentation.screen.feeds.utils.ArticlesPreviewAdapter
...@@ -38,6 +41,24 @@ class FeedsScreenController : ...@@ -38,6 +41,24 @@ class FeedsScreenController :
, FeedsScreenPresenter>() , FeedsScreenPresenter>()
, FeedsScreen { , FeedsScreen {
override fun onCameraSelected(): Observable<WebCamModel> =
(camsRecyclerView.adapter as CamsListAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
override fun onArticleSelected(): Observable<ArticlePreviewModel> =
(feedsRecyclerView.adapter as ArticlesPreviewAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
override fun onAlbumSelected(): Observable<AlbumPreviewModel> =
(devProgressRecyclerView.adapter as AlbumsPreviewAdapter).onItemClicked
.debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
override fun feedsTabSelected(): Observable<Int> override fun feedsTabSelected(): Observable<Int>
= feedsTabs.selections() = feedsTabs.selections()
.debounce (200L, TimeUnit.MILLISECONDS) .debounce (200L, TimeUnit.MILLISECONDS)
...@@ -135,6 +156,9 @@ class FeedsScreenController : ...@@ -135,6 +156,9 @@ class FeedsScreenController :
is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState) is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState)
is FeedsScreenViewState.RestoreView -> render(viewState) is FeedsScreenViewState.RestoreView -> render(viewState)
is FeedsScreenViewState.ToArticlesScreen -> render(viewState) is FeedsScreenViewState.ToArticlesScreen -> render(viewState)
is FeedsScreenViewState.ToWebCam -> render(viewState)
is FeedsScreenViewState.ToArticle -> render(viewState)
is FeedsScreenViewState.ToAlbum -> render(viewState)
is FeedsScreenViewState.SomeError -> render(viewState) is FeedsScreenViewState.SomeError -> render(viewState)
} }
} }
...@@ -151,6 +175,24 @@ class FeedsScreenController : ...@@ -151,6 +175,24 @@ class FeedsScreenController :
) )
} }
private fun render(viewState: FeedsScreenViewState.ToWebCam) {
TODO("to webcam screen")
// router.pushController(
// RouterTransaction.with(ArticlesScreenController(viewState.feedId))
// .popChangeHandler(FadeChangeHandler())
// .pushChangeHandler(FadeChangeHandler())
// )
}
private fun render(viewState: FeedsScreenViewState.ToArticle) {
TODO("to article screen")
}
private fun render(viewState: FeedsScreenViewState.ToAlbum) {
TODO("to album screen")
}
private fun render(viewState: FeedsScreenViewState.SomeError) = private fun render(viewState: FeedsScreenViewState.SomeError) =
showError(viewState.exception) showError(viewState.exception)
......
...@@ -74,6 +74,22 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -74,6 +74,22 @@ class FeedsScreenPresenter @Inject constructor(
} }
.onErrorReturn (::parseError) .onErrorReturn (::parseError)
val selectCamera = intent(FeedsScreen::onCameraSelected)
.map<FeedsScreenViewState> {
FeedsScreenViewState.ToWebCam(it.index,it.streamUrl)
}
val selectArticle = intent(FeedsScreen::onArticleSelected)
.map<FeedsScreenViewState> {
FeedsScreenViewState.ToArticle(it.articleId)
}
val selectAlbum = intent(FeedsScreen::onAlbumSelected)
.map<FeedsScreenViewState> {
FeedsScreenViewState.ToAlbum(it.albumId)
}
val getNewArticlesPage = intent(FeedsScreen::requsetsNewArticles) val getNewArticlesPage = intent(FeedsScreen::requsetsNewArticles)
.flatMap { interactor.fetchArticles(it.first.feedId, FEED_PREVIEW_PAGE_SIZE,it.second) } .flatMap { interactor.fetchArticles(it.first.feedId, FEED_PREVIEW_PAGE_SIZE,it.second) }
.map<FeedsScreenViewState> { .map<FeedsScreenViewState> {
...@@ -90,6 +106,9 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -90,6 +106,9 @@ class FeedsScreenPresenter @Inject constructor(
.mergeWith(fetchCams) .mergeWith(fetchCams)
.mergeWith(getNewArticlesPage) .mergeWith(getNewArticlesPage)
.mergeWith(switchToAllArtiles) .mergeWith(switchToAllArtiles)
.mergeWith(selectCamera)
.mergeWith(selectAlbum)
.mergeWith(selectArticle)
.doOnError{ Timber.e(it)} .doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -26,6 +26,12 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() { ...@@ -26,6 +26,12 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : FeedsScreenViewState() class SomeError(val exception: ExceptionString) : FeedsScreenViewState()
class ToArticlesScreen(val feedId:Int) : FeedsScreenViewState() class ToArticlesScreen(val feedId:Int) : FeedsScreenViewState()
class ToArticle(val articleId:Int) : FeedsScreenViewState()
class ToAlbum(val albumId:Int) : FeedsScreenViewState()
class ToWebCam(val camId:Int, val camUrl:String) : FeedsScreenViewState()
} }
data class RestoreModel( data class RestoreModel(
......
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