Commit 0990432a authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

update feed alias and dependencies fixes

parent 3c89dac9
...@@ -18,7 +18,6 @@ interface IDb { ...@@ -18,7 +18,6 @@ interface IDb {
fun <T : List<Persistable>> blockingUpsert(entity: T) fun <T : List<Persistable>> blockingUpsert(entity: T)
fun userObservableResult(uuid: Int): Observable<ReactiveResult<UserEntity>> fun userObservableResult(uuid: Int): Observable<ReactiveResult<UserEntity>>
fun fetchArticles(feedAlias: String, pageSize: Int, startIndex: Int): Observable<ArticleEntity> fun fetchArticles(feedAlias: String, pageSize: Int, startIndex: Int): Observable<ArticleEntity>
fun getFeed(feedId: Int): ReactiveResult<FeedEntity>
fun getTopLevelAlbums(): Observable<ImageAlbumEntity> fun getTopLevelAlbums(): Observable<ImageAlbumEntity>
fun getChildAlbums(parentId: Int): Observable<ImageAlbumEntity> fun getChildAlbums(parentId: Int): Observable<ImageAlbumEntity>
fun checkIfExistsAlbumJunction(albumId: Int, parentAlbumId: Int): ImageAlbumJunctionEntity? fun checkIfExistsAlbumJunction(albumId: Int, parentAlbumId: Int): ImageAlbumJunctionEntity?
......
...@@ -63,10 +63,6 @@ class RequeryRepository @Inject constructor( ...@@ -63,10 +63,6 @@ class RequeryRepository @Inject constructor(
override fun fetchFeeds(): Observable<FeedEntity> = override fun fetchFeeds(): Observable<FeedEntity> =
fetchAll<FeedEntity>().get().observable() fetchAll<FeedEntity>().get().observable()
override fun getFeed(feedId:Int): ReactiveResult<FeedEntity> =
fetchAll<FeedEntity>().where(FeedEntity.ID.eq(feedId))
.get()
override fun getFeed(feedAlias:String): ReactiveResult<FeedEntity> = override fun getFeed(feedAlias:String): ReactiveResult<FeedEntity> =
fetchAll<FeedEntity>().where(FeedEntity.ALIAS.eq(feedAlias)) fetchAll<FeedEntity>().where(FeedEntity.ALIAS.eq(feedAlias))
.get() .get()
...@@ -89,7 +85,7 @@ class RequeryRepository @Inject constructor( ...@@ -89,7 +85,7 @@ class RequeryRepository @Inject constructor(
override fun fetchArticles(feedAlias:String,pageSize:Int,startIndex:Int) override fun fetchArticles(feedAlias:String,pageSize:Int,startIndex:Int)
: Observable<ArticleEntity> = : Observable<ArticleEntity> =
fetchAll<ArticleEntity>() fetchAll<ArticleEntity>()
.where(ArticleEntity.FEED_ID.eq(1)) .where(ArticleEntity.FEED_ID.eq(feedAlias))
.orderBy(ArticleEntity.PUBLISHED.desc()) .orderBy(ArticleEntity.PUBLISHED.desc())
.limit(pageSize) .limit(pageSize)
.offset(startIndex) .offset(startIndex)
......
...@@ -26,15 +26,12 @@ interface DataComponent{ ...@@ -26,15 +26,12 @@ interface DataComponent{
@Module(includes = [DataModule::class, RetrofitModule::class, DbModule::class,LocalStorage::class]) @Module(includes = [DataModule::class, RetrofitModule::class, DbModule::class,LocalStorage::class])
abstract class ContractRepositoryModule { abstract class ContractRepositoryModule {
@Singleton
@Binds @Binds
abstract fun provideAuth(contract:AuthContractModule):AuthContract abstract fun provideAuth(contract:AuthContractModule):AuthContract
@Singleton
@Binds @Binds
abstract fun provideFeedsContract(impl: FeedsContractModule): FeedsContract abstract fun provideFeedsContract(impl: FeedsContractModule): FeedsContract
@Singleton
@Binds @Binds
abstract fun provideDevProgressContract(impl: AlbumsContractModule): DevProgressContract abstract fun provideDevProgressContract(impl: AlbumsContractModule): DevProgressContract
} }
......
...@@ -11,11 +11,11 @@ import javax.inject.Inject ...@@ -11,11 +11,11 @@ import javax.inject.Inject
class ArticlesInteractor @Inject constructor( class ArticlesInteractor @Inject constructor(
) { ) {
fun fetchArticles(feedId: Int): Single<ArticlesPreviewModel> = Single.just( fun fetchArticles(feedAlias: String): Single<ArticlesPreviewModel> = Single.just(
when (feedId) { when (feedAlias) {
1 -> FeedsInteractor.testNewsArticles "news" -> FeedsInteractor.testNewsArticles
2 -> FeedsInteractor.testBlogsArticles "blog" -> FeedsInteractor.testBlogsArticles
3 -> FeedsInteractor.testDevArticles "constructors_blog" -> FeedsInteractor.testDevArticles
else -> error("unknown feedId") else -> error("unknown feedId")
} }
) )
......
...@@ -20,8 +20,8 @@ class FeedsInteractor @Inject constructor( ...@@ -20,8 +20,8 @@ class FeedsInteractor @Inject constructor(
feedsUseCase.getFeeds().map {FeedsHeaderModel(it)} feedsUseCase.getFeeds().map {FeedsHeaderModel(it)}
//Single.just(testFeeds) //Single.just(testFeeds)
fun fetchArticles(feedId: Int): Observable<ArticlesPreviewModel> = fun fetchArticles(feedAlias:String): Observable<ArticlesPreviewModel> =
feedsUseCase.getArticles(feedId) feedsUseCase.getArticles(feedAlias)
// Single.just( // Single.just(
// when (feedId) { // when (feedId) {
// 1 -> testNewsArticles // 1 -> testNewsArticles
...@@ -30,8 +30,8 @@ class FeedsInteractor @Inject constructor( ...@@ -30,8 +30,8 @@ class FeedsInteractor @Inject constructor(
// else -> error("unknown feedId") // else -> error("unknown feedId")
// } // }
// ) // )
fun fetchArticles(feedId: Int,pageSize:Int,startIndex:Int): Observable<ArticlesPreviewModel> = fun fetchArticles(feedAlias:String,pageSize:Int,startIndex:Int): Observable<ArticlesPreviewModel> =
feedsUseCase.fetchArticlesPage(feedId,pageSize,startIndex) feedsUseCase.fetchArticlesPage(feedAlias,pageSize,startIndex)
fun fetchAlbums(): Observable<List<AlbumPreviewModel>> = albumsUseCase.getProgressAlbums() fun fetchAlbums(): Observable<List<AlbumPreviewModel>> = albumsUseCase.getProgressAlbums()
...@@ -50,14 +50,15 @@ class FeedsInteractor @Inject constructor( ...@@ -50,14 +50,15 @@ class FeedsInteractor @Inject constructor(
val testFeeds = FeedsHeaderModel( val testFeeds = FeedsHeaderModel(
listOf( listOf(
FeedModel(1, "НОВОСТИ"), FeedModel(
FeedModel(2, "БЛОГИ"), "news", "НОВОСТИ"),
FeedModel(2, "БЛОГ СТРОИТЕЛЬСТВА") FeedModel("news", "БЛОГИ"),
FeedModel("news", "БЛОГ СТРОИТЕЛЬСТВА")
) )
) )
val testNewsArticles = ArticlesPreviewModel( val testNewsArticles = ArticlesPreviewModel(
1, "news",
listOf( listOf(
ArticlePreviewModel( ArticlePreviewModel(
1 1
...@@ -87,7 +88,7 @@ class FeedsInteractor @Inject constructor( ...@@ -87,7 +88,7 @@ class FeedsInteractor @Inject constructor(
) )
val testBlogsArticles = ArticlesPreviewModel( val testBlogsArticles = ArticlesPreviewModel(
2, "news",
listOf( listOf(
ArticlePreviewModel( ArticlePreviewModel(
1 1
...@@ -117,7 +118,7 @@ class FeedsInteractor @Inject constructor( ...@@ -117,7 +118,7 @@ class FeedsInteractor @Inject constructor(
) )
val testDevArticles = ArticlesPreviewModel( val testDevArticles = ArticlesPreviewModel(
3, "news",
listOf( listOf(
ArticlePreviewModel( ArticlePreviewModel(
1 1
......
...@@ -11,7 +11,7 @@ import java.util.* ...@@ -11,7 +11,7 @@ import java.util.*
const val DEFAULT_ROOM_PARK_PREVIEW = "https://room-park.ru/assets/news_articles/preview/00/00/00/15-fe1886.jpeg" const val DEFAULT_ROOM_PARK_PREVIEW = "https://room-park.ru/assets/news_articles/preview/00/00/00/15-fe1886.jpeg"
data class FeedModel(val feedId:Int, val title:String, val alias:String? = null) data class FeedModel(val title:String, val alias:String)
data class FeedsHeaderModel(val feeds:List<FeedModel>) data class FeedsHeaderModel(val feeds:List<FeedModel>)
...@@ -44,7 +44,6 @@ data class ArticleModel( ...@@ -44,7 +44,6 @@ data class ArticleModel(
) )
fun fromEntity(entity: FeedEntity):FeedModel = FeedModel( fun fromEntity(entity: FeedEntity):FeedModel = FeedModel(
feedId = entity.id,
title = entity.title, title = entity.title,
alias = entity.alias alias = entity.alias
) )
...@@ -60,7 +59,7 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel( ...@@ -60,7 +59,7 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
fun fromEntity(parentId:String,entity: List<ArticleEntity>):ArticlesPreviewModel = fun fromEntity(parentId:String,entity: List<ArticleEntity>):ArticlesPreviewModel =
ArticlesPreviewModel( ArticlesPreviewModel(
parentFeedId = parentId, parentFeedAlias = parentId,
articles = fromEntity(entity,::fromEntity) articles = fromEntity(entity,::fromEntity)
) )
......
...@@ -12,11 +12,11 @@ class FeedUseCase @Inject constructor( ...@@ -12,11 +12,11 @@ class FeedUseCase @Inject constructor(
){ ){
fun getFeeds() = contract.fetchFeeds() fun getFeeds() = contract.fetchFeeds()
fun getArticles(feedId:Int) = fun getArticles(feedAlias:String) =
contract.fetchFeedObservable(feedId) contract.fetchFeedObservable(feedAlias)
fun fetchArticlesPage(feedId:Int,pageSize:Int,startIndex:Int) = fun fetchArticlesPage(feedAlias:String,pageSize:Int,startIndex:Int) =
contract.fetchFeedObservable(feedId,pageSize,startIndex) contract.fetchFeedObservable(feedAlias,pageSize,startIndex)
fun getArticle(articleId:Int) = fun getArticle(articleId:Int) =
......
...@@ -21,7 +21,7 @@ import javax.inject.Inject ...@@ -21,7 +21,7 @@ import javax.inject.Inject
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
*/ */
private const val FEED_ID = "DIRECT_FEED_ID_KEY" const val FEED_ALIAS = "DIRECT_FEED_ID_KEY"
class ArticlesScreenController : class ArticlesScreenController :
BigantoBaseController<ArticlesScreenViewState BigantoBaseController<ArticlesScreenViewState
...@@ -32,7 +32,7 @@ class ArticlesScreenController : ...@@ -32,7 +32,7 @@ class ArticlesScreenController :
constructor() constructor()
constructor(feedId:Int):super(bundleOf(FEED_ID to feedId)) constructor(feedAlias:String):super(bundleOf(FEED_ALIAS to feedAlias))
override fun injectDependencies() { override fun injectDependencies() {
getComponent() getComponent()
...@@ -102,7 +102,7 @@ class ArticlesScreenController : ...@@ -102,7 +102,7 @@ class ArticlesScreenController :
} }
private fun getComponent() = DaggerArticlesScreenComponent.factory() private fun getComponent() = DaggerArticlesScreenComponent.factory()
.create(args.getInt(FEED_ID) .create(args.getString(FEED_ALIAS)!!
,RoomParkApplication.component,activity as RoomParkMainActivity) ,RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this) .inject(this)
......
...@@ -20,7 +20,7 @@ interface ArticlesScreenComponent { ...@@ -20,7 +20,7 @@ interface ArticlesScreenComponent {
@Component.Factory @Component.Factory
interface Factory{ interface Factory{
fun create( fun create(
@BindsInstance @Named("FEED_ID_INT") feed:Int @BindsInstance @Named(FEED_ALIAS) feed:String
, appComponent: AppComponent , appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity ,@BindsInstance activity: RoomParkMainActivity
): ArticlesScreenComponent ): ArticlesScreenComponent
......
...@@ -15,7 +15,7 @@ import javax.inject.Named ...@@ -15,7 +15,7 @@ import javax.inject.Named
class ArticlesScreenPresenter @Inject constructor( class ArticlesScreenPresenter @Inject constructor(
@Named("FEED_ID_INT") private val feedId:Int, @Named(FEED_ALIAS) private val feedId:String,
private val interactor: ArticlesInteractor private val interactor: ArticlesInteractor
) )
: BigantoBasePresenter<ArticlesScreen, ArticlesScreenViewState>() { : BigantoBasePresenter<ArticlesScreen, ArticlesScreenViewState>() {
......
...@@ -12,7 +12,7 @@ import io.reactivex.Observable ...@@ -12,7 +12,7 @@ import io.reactivex.Observable
*/ */
interface FeedsScreen : BigantoBaseContract<FeedsScreenViewState> { interface FeedsScreen : BigantoBaseContract<FeedsScreenViewState> {
fun feedsTabSelected(): Observable<Int> fun feedsTabSelected(): Observable<String>
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 onCameraSelected(): Observable<WebCamModel>
......
...@@ -60,11 +60,11 @@ class FeedsScreenController : ...@@ -60,11 +60,11 @@ class FeedsScreenController :
.debounce (120L, TimeUnit.MILLISECONDS) .debounce (120L, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
override fun feedsTabSelected(): Observable<Int> override fun feedsTabSelected(): Observable<String>
= feedsTabs.selections() = feedsTabs.selections()
.debounce (200L, TimeUnit.MILLISECONDS) .debounce (200L, TimeUnit.MILLISECONDS)
.map { it.position } .map { it.position }
.map { storedFeedsList[it].feedId } .map { storedFeedsList[it].alias }
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doOnNext { allFeedArticles.text = "ВСЕ ${allFeedName(it)} →" } .doOnNext { allFeedArticles.text = "ВСЕ ${allFeedName(it)} →" }
...@@ -170,7 +170,7 @@ class FeedsScreenController : ...@@ -170,7 +170,7 @@ class FeedsScreenController :
private fun render(viewState: FeedsScreenViewState.ToArticlesScreen) { private fun render(viewState: FeedsScreenViewState.ToArticlesScreen) {
router.pushController( router.pushController(
RouterTransaction.with(ArticlesScreenController(viewState.feedId)) RouterTransaction.with(ArticlesScreenController(viewState.feedAlias))
.popChangeHandler(FadeChangeHandler()) .popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler()) .pushChangeHandler(FadeChangeHandler())
) )
...@@ -201,7 +201,7 @@ class FeedsScreenController : ...@@ -201,7 +201,7 @@ class FeedsScreenController :
private fun render(viewState: FeedsScreenViewState.SomeError) = private fun render(viewState: FeedsScreenViewState.SomeError) =
showError(viewState.exception) showError(viewState.exception)
private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ" private fun allFeedName(feedAlias:String) = if (feedAlias=="news") "НОВОСТИ" else "БЛОГИ"
private fun render(viewState: FeedsScreenViewState.FeedsPages){ private fun render(viewState: FeedsScreenViewState.FeedsPages){
feedsTabs.removeAllTabs() feedsTabs.removeAllTabs()
...@@ -209,7 +209,7 @@ class FeedsScreenController : ...@@ -209,7 +209,7 @@ class FeedsScreenController :
viewState.items.forEach {feed -> viewState.items.forEach {feed ->
val tab = feedsTabs.newTab() val tab = feedsTabs.newTab()
.setCustomView(R.layout.feeds_tab_view) .setCustomView(R.layout.feeds_tab_view)
.setTag(feed.feedId) .setTag(feed.alias)
tab.customView tab.customView
?.let { ?.let {
it.findViewById<TextView>(R.id.tab_title)?.text = feed.title it.findViewById<TextView>(R.id.tab_title)?.text = feed.title
...@@ -250,7 +250,7 @@ class FeedsScreenController : ...@@ -250,7 +250,7 @@ class FeedsScreenController :
viewState.restore.feeds.forEach {feed -> viewState.restore.feeds.forEach {feed ->
val tab = feedsTabs.newTab() val tab = feedsTabs.newTab()
.setCustomView(R.layout.feeds_tab_view) .setCustomView(R.layout.feeds_tab_view)
.setTag(feed.feedId) .setTag(feed.alias)
tab.customView tab.customView
?.let { ?.let {
it.findViewById<TextView>(R.id.tab_title)?.text = feed.title it.findViewById<TextView>(R.id.tab_title)?.text = feed.title
......
...@@ -70,7 +70,7 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -70,7 +70,7 @@ class FeedsScreenPresenter @Inject constructor(
val switchToAllArtiles = intent(FeedsScreen::onAllFeedArticles) val switchToAllArtiles = intent(FeedsScreen::onAllFeedArticles)
.map<FeedsScreenViewState> { .map<FeedsScreenViewState> {
FeedsScreenViewState.ToArticlesScreen(it.feedId) FeedsScreenViewState.ToArticlesScreen(it.alias)
} }
.onErrorReturn (::parseError) .onErrorReturn (::parseError)
...@@ -91,7 +91,7 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -91,7 +91,7 @@ class FeedsScreenPresenter @Inject constructor(
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.alias, FEED_PREVIEW_PAGE_SIZE,it.second) }
.map<FeedsScreenViewState> { .map<FeedsScreenViewState> {
restoreModel.articles = it.articles restoreModel.articles = it.articles
Timber.d("arrived list: ${it.articles.size}") Timber.d("arrived list: ${it.articles.size}")
......
...@@ -25,7 +25,7 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() { ...@@ -25,7 +25,7 @@ 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 feedAlias:String) : FeedsScreenViewState()
class ToArticle(val articleId:Int) : FeedsScreenViewState() class ToArticle(val articleId:Int) : FeedsScreenViewState()
......
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