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