Commit 9c0ec0ce authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

Merge branch 'develop' into feature/article_screen_impl

parents 87390083 6bc7f456
...@@ -31,12 +31,12 @@ abstract class BigantoBasePresenter<V : MvpView, VS> ...@@ -31,12 +31,12 @@ abstract class BigantoBasePresenter<V : MvpView, VS>
open fun parseError(t: Throwable) : VS = open fun parseError(t: Throwable) : VS =
when (t) { when (t) {
is CustomApiException ->{ is CustomApiException ->{
Timber.d("CustomApiException ${t.messageStringId} / ${t.customMessage}") Timber.e("CustomApiException ${t.messageStringId} / ${t.customMessage}")
parse(t) parse(t)
} }
is NoNetworkException -> parse(t) is NoNetworkException -> parse(t)
else -> parse(t) else -> {Timber.e(t);parse(t)}
} }
private fun parse(e: CustomApiException) = onCodeReturn(e) private fun parse(e: CustomApiException) = onCodeReturn(e)
......
...@@ -62,7 +62,7 @@ class AlbumsContractModule @Inject constructor( ...@@ -62,7 +62,7 @@ class AlbumsContractModule @Inject constructor(
private fun fetchTopLevelAlbums(): Observable<List<AlbumPreviewModel>> = private fun fetchTopLevelAlbums(): Observable<List<AlbumPreviewModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchTopLevelAlbumsApi,fetchTopLevelAlbumsDb) arrayListOf(fetchTopLevelAlbumsApi,fetchTopLevelAlbumsDb)
).map { fromEntity(it,::fromEntity) } ).doOnNext { Timber.d("got entity $it") }.map { fromEntity(it,::fromEntity) }
private fun fetchAlbumsApi(parentAlbumId:Int) = private fun fetchAlbumsApi(parentAlbumId:Int) =
......
...@@ -52,10 +52,10 @@ class FeedsContractModule @Inject constructor( ...@@ -52,10 +52,10 @@ class FeedsContractModule @Inject constructor(
throw CustomApiException.UnknownCustomApiException(-1,null,"Unknown Feed!") throw CustomApiException.UnknownCustomApiException(-1,null,"Unknown Feed!")
} }
else { else {
Timber.d("page index: " + return api.getArticlesPage(
"${startIndex.toDouble()/pageSize.toDouble()} -- -" + feed.alias
"${floor(startIndex.toDouble()/pageSize.toDouble()).toInt()+1}") , pageSize
return api.getArticlesPage(feed.alias, pageSize, floor(startIndex.toDouble()/pageSize.toDouble()).toInt()+1) , floor(startIndex.toDouble()/pageSize.toDouble()).toInt()+1)
.doOnNext { Timber.d("raw0 $it") } .doOnNext { Timber.d("raw0 $it") }
.map { it.items } .map { it.items }
.map { fromRaw(it, feedId) } .map { fromRaw(it, feedId) }
......
...@@ -59,6 +59,7 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi ...@@ -59,6 +59,7 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
override fun getFeeds(): Observable<List<FeedRaw>> = override fun getFeeds(): Observable<List<FeedRaw>> =
api.getFeeds() api.getFeeds()
.subscribeOn(Schedulers.io())
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
override fun getArticlesPage( override fun getArticlesPage(
...@@ -71,14 +72,17 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi ...@@ -71,14 +72,17 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
override fun getArticle(id: Int): Observable<ArticleRaw> = override fun getArticle(id: Int): Observable<ArticleRaw> =
api.getArticle(id = id) api.getArticle(id = id)
.subscribeOn(Schedulers.io())
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
override fun getAlbums(parentId: Int?): Observable<List<ImageAlbumRaw>> = override fun getAlbums(parentId: Int?): Observable<List<ImageAlbumRaw>> =
api.getAlbums(id = parentId) api.getAlbums(id = parentId)
.subscribeOn(Schedulers.io())
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
override fun getPhotos(parentId: Int): Observable<List<NewsPhotoRaw>> = override fun getPhotos(parentId: Int): Observable<List<NewsPhotoRaw>> =
api.getPhotos(id = parentId) api.getPhotos(id = parentId)
.subscribeOn(Schedulers.io())
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
override fun getEstatePlanTypes(estateId: Int): Observable<List<PlanTypeRaw>> = override fun getEstatePlanTypes(estateId: Int): Observable<List<PlanTypeRaw>> =
......
...@@ -7,6 +7,9 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi ...@@ -7,6 +7,9 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.IDb import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.contract.DevProgressContract
import com.biganto.visual.roompark.domain.contract.FeedsContract
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
...@@ -35,16 +38,16 @@ import javax.inject.Singleton ...@@ -35,16 +38,16 @@ import javax.inject.Singleton
AndroidSupportInjectionModule::class, AndroidSupportInjectionModule::class,
// MappingProvider::class, // MappingProvider::class,
ActivityModule::class, ActivityModule::class,
// ContractRepositoryModule::class, ContractRepositoryModule::class,
AppActivityModule ::class]) AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{ interface AppComponent : AndroidInjector<RoomParkApplication>{
// fun authC():AuthContract fun authC(): AuthContract
//
// fun feedsC():FeedsContract fun feedsC(): FeedsContract
// fun feedsAlb(): DevProgressContract fun feedsAlb(): DevProgressContract
......
...@@ -26,12 +26,15 @@ interface DataComponent{ ...@@ -26,12 +26,15 @@ 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
} }
......
...@@ -146,8 +146,8 @@ class FeedsInteractor @Inject constructor( ...@@ -146,8 +146,8 @@ class FeedsInteractor @Inject constructor(
) )
) )
val albumsPreviews = listOf<AlbumPreviewModel>( val albumsPreviews = listOf<AlbumPhotoPreviewModel>(
AlbumPreviewModel( AlbumPhotoPreviewModel(
1, 1,
2, 2,
Date(3131231L), Date(3131231L),
...@@ -155,7 +155,7 @@ class FeedsInteractor @Inject constructor( ...@@ -155,7 +155,7 @@ class FeedsInteractor @Inject constructor(
"https://room-park.ru/assets/gallery_images/image_2600/00/00/02/764-1d9795.png", "https://room-park.ru/assets/gallery_images/image_2600/00/00/02/764-1d9795.png",
false false
), ),
AlbumPreviewModel( AlbumPhotoPreviewModel(
1, 1,
2, 2,
Date(31312323421L), Date(31312323421L),
...@@ -163,7 +163,7 @@ class FeedsInteractor @Inject constructor( ...@@ -163,7 +163,7 @@ class FeedsInteractor @Inject constructor(
"https://room-park.ru/assets/gallery_images/image_2600/00/00/02/626-8afd4a.jpeg", "https://room-park.ru/assets/gallery_images/image_2600/00/00/02/626-8afd4a.jpeg",
false false
), ),
AlbumPreviewModel( AlbumPhotoPreviewModel(
1, 1,
2, 2,
Date(3131232131L), Date(3131232131L),
......
...@@ -9,6 +9,13 @@ import java.util.* ...@@ -9,6 +9,13 @@ import java.util.*
data class AlbumPreviewModel( data class AlbumPreviewModel(
val albumId:Int,
val parentId:Int,
val title:String,
val isRead:Boolean
)
data class AlbumPhotoPreviewModel(
val albumId:Int, val albumId:Int,
val parentId:Int, val parentId:Int,
val published: Date, val published: Date,
...@@ -40,8 +47,6 @@ fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel = ...@@ -40,8 +47,6 @@ fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel =
AlbumPreviewModel( AlbumPreviewModel(
albumId = entity.id, albumId = entity.id,
parentId = -1, parentId = -1,
published = entity.published,
title = entity.title, title = entity.title,
previewUrl = "" ,// SHOULD BE FIRST AVALIABLE IMAGE FROM ALBUM PHOTOS
isRead = false isRead = false
) )
\ No newline at end of file
...@@ -2,14 +2,10 @@ package com.biganto.visual.roompark.presentation.screen.feeds ...@@ -2,14 +2,10 @@ package com.biganto.visual.roompark.presentation.screen.feeds
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.data_provider.AlbumsContractModule
import com.biganto.visual.roompark.data.data_provider.FeedsContractModule
import com.biganto.visual.roompark.data.service.user_session.IUserSession import com.biganto.visual.roompark.data.service.user_session.IUserSession
import com.biganto.visual.roompark.data.service.user_session.UserSessionService import com.biganto.visual.roompark.data.service.user_session.UserSessionService
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.contract.DevProgressContract
import com.biganto.visual.roompark.domain.contract.FeedsContract
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
...@@ -41,13 +37,13 @@ abstract class FeedsScreenModule{ ...@@ -41,13 +37,13 @@ abstract class FeedsScreenModule{
@Binds @Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen // @PerScreen
@Binds // @Binds
abstract fun provideContract(impl: FeedsContractModule): FeedsContract // abstract fun provideContract(impl: FeedsContractModule): FeedsContract
//
@PerScreen // @PerScreen
@Binds // @Binds
abstract fun provideDevContract(impl: AlbumsContractModule): DevProgressContract // abstract fun provideDevContract(impl: AlbumsContractModule): DevProgressContract
@PerScreen @PerScreen
......
...@@ -47,6 +47,7 @@ class FeedsScreenPresenter @Inject constructor( ...@@ -47,6 +47,7 @@ class FeedsScreenPresenter @Inject constructor(
val fetchAlbums = interactor.fetchAlbums() val fetchAlbums = interactor.fetchAlbums()
.map <FeedsScreenViewState>{ .map <FeedsScreenViewState>{
Timber.d("got albums: $it")
restoreModel.albums = it restoreModel.albums = it
FeedsScreenViewState.AlbumsPages(it) FeedsScreenViewState.AlbumsPages(it)
} }
......
...@@ -8,7 +8,6 @@ import com.biganto.visual.roompark.R ...@@ -8,7 +8,6 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
...@@ -35,11 +34,9 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>( ...@@ -35,11 +34,9 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
@BindView(R.id.card_updated) lateinit var articleDate:TextView @BindView(R.id.card_updated) lateinit var articleDate:TextView
override fun onViewBound(model: AlbumPreviewModel) { override fun onViewBound(model: AlbumPreviewModel) {
articleDate.text = dateFormatter.format(model.published) // articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title articleTitle.text = model.title
Picasso.get() // Picasso.ge1preview)
.load(model.previewUrl)
.into(preview)
} }
} }
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