Commit 5d14095e authored by Vladislav's avatar Vladislav

added item selected impls

parent 6f081dd0
package com.biganto.visual.roompark.presentation.screen.feeds
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.WebCamModel
import io.reactivex.Observable
/**
......@@ -12,6 +15,9 @@ interface FeedsScreen : BigantoBaseContract<FeedsScreenViewState> {
fun feedsTabSelected(): Observable<Int>
fun requsetsNewArticles(): Observable<Pair<FeedModel, Int>>
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
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
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.WebCamModel
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.ArticlesPreviewAdapter
......@@ -38,6 +41,24 @@ class FeedsScreenController :
, FeedsScreenPresenter>()
, 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>
= feedsTabs.selections()
.debounce (200L, TimeUnit.MILLISECONDS)
......@@ -114,8 +135,8 @@ class FeedsScreenController :
override fun onAllFeedArticles(): Observable<FeedModel> =
allFeedArticles.clicks()
.map{ feedsTabs.getTabAt(feedsTabs.selectedTabPosition)}
.map { storedFeedsList[it.position] }
.map{ feedsTabs.getTabAt(feedsTabs.selectedTabPosition)}
.map { storedFeedsList[it.position] }
override fun onViewBound(v: View) {
toolBar.hideAll()
......@@ -135,6 +156,9 @@ class FeedsScreenController :
is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState)
is FeedsScreenViewState.RestoreView -> 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)
}
}
......@@ -151,7 +175,25 @@ class FeedsScreenController :
)
}
private fun render(viewState: FeedsScreenViewState.SomeError) =
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) =
showError(viewState.exception)
private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ"
......
......@@ -73,6 +73,22 @@ class FeedsScreenPresenter @Inject constructor(
}
.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)
.flatMap { interactor.fetchArticles(it.first.feedId, FEED_PREVIEW_PAGE_SIZE,it.second) }
.map<FeedsScreenViewState> {
......@@ -89,6 +105,9 @@ class FeedsScreenPresenter @Inject constructor(
.mergeWith(fetchCams)
.mergeWith(getNewArticlesPage)
.mergeWith(switchToAllArtiles)
.mergeWith(selectCamera)
.mergeWith(selectAlbum)
.mergeWith(selectArticle)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
......@@ -26,6 +26,12 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : 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(
......
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