Commit cc82fe5f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

provide plan sizes to presentation;

fix di invalid name
parent 53a5764f
...@@ -78,7 +78,7 @@ class PlanRepository @Inject constructor( ...@@ -78,7 +78,7 @@ class PlanRepository @Inject constructor(
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
private fun getPlanFile(featuresVariant: PlanFeaturesVariant) override fun getPlanFile(featuresVariant: PlanFeaturesVariant)
= getPlanFile( = getPlanFile(
estateId = featuresVariant.estateId, estateId = featuresVariant.estateId,
planId = featuresVariant.planId, planId = featuresVariant.planId,
...@@ -88,7 +88,7 @@ class PlanRepository @Inject constructor( ...@@ -88,7 +88,7 @@ class PlanRepository @Inject constructor(
electric = featuresVariant.electric electric = featuresVariant.electric
) )
private fun getPlanFile(estateId: Int fun getPlanFile(estateId: Int
, planId:Int , planId:Int
, furniture:Boolean? = null , furniture:Boolean? = null
, sizes:Boolean? = null , sizes:Boolean? = null
...@@ -136,6 +136,7 @@ class PlanRepository @Inject constructor( ...@@ -136,6 +136,7 @@ class PlanRepository @Inject constructor(
// fun getPlanRequestString(estateId: Int // fun getPlanRequestString(estateId: Int
// , planId:Int // , planId:Int
// , furniture:Boolean // , furniture:Boolean
......
...@@ -62,7 +62,7 @@ abstract class ContractRepositoryModule { ...@@ -62,7 +62,7 @@ abstract class ContractRepositoryModule {
@Binds @Binds
@Singleton @Singleton
abstract fun provideTourContract(impl: PlanRepository): FlatPlanContract abstract fun providePlanContract(impl: PlanRepository): FlatPlanContract
} }
......
package com.biganto.visual.roompark.domain.contract package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.data.data_provider.PlanFeaturesVariant
import com.biganto.visual.roompark.domain.model.PlanPresetModel import com.biganto.visual.roompark.domain.model.PlanPresetModel
import io.reactivex.Observable import io.reactivex.Observable
import java.io.File
/** /**
* Created by Vladislav Bogdashkin on 20.04.2020. * Created by Vladislav Bogdashkin on 20.04.2020.
...@@ -18,4 +20,5 @@ interface FlatPlanContract{ ...@@ -18,4 +20,5 @@ interface FlatPlanContract{
, walls:Boolean? , walls:Boolean?
, electric:Boolean?): Observable<String> , electric:Boolean?): Observable<String>
fun getPlanFile(featuresVariant: PlanFeaturesVariant): File
} }
\ No newline at end of file
...@@ -28,11 +28,14 @@ class SettingsInteractor @Inject constructor( ...@@ -28,11 +28,14 @@ class SettingsInteractor @Inject constructor(
private val settingsUseCase: SettingsUseCase, private val settingsUseCase: SettingsUseCase,
private val activity: BaseRoomParkActivity, private val activity: BaseRoomParkActivity,
private val subUc: SubscriptionUseCase, private val subUc: SubscriptionUseCase,
private val toursUc: TourPreviewsUseCase private val toursUc: TourPreviewsUseCase,
private val planTypes: PlanTypesUseCase
){ ){
fun fetchToursSizes() = toursUc.fetchToursSizes() fun fetchToursSizes() = toursUc.fetchToursSizes()
fun fetchPlanTypesSizes() = planTypes.fetchNotDownloadedPlansSizes()
private fun startDownloadService() { private fun startDownloadService() {
val i = Intent(activity, DownloadManagerService::class.java) val i = Intent(activity, DownloadManagerService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
......
package com.biganto.visual.roompark.domain.use_case package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.data.data_provider.featuresVariants
import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import com.biganto.visual.roompark.domain.contract.AuthContract import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.contract.FlatPlanContract import com.biganto.visual.roompark.domain.contract.FlatPlanContract
import io.reactivex.BackpressureStrategy
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -13,20 +18,33 @@ class PlanTypesUseCase @Inject constructor( ...@@ -13,20 +18,33 @@ class PlanTypesUseCase @Inject constructor(
private val auth:AuthContract private val auth:AuthContract
){ ){
// fun fetchNotDownloadedPlansSizes() = fun fetchNotDownloadedPlansSizes() =
// auth.currentUser() auth.currentUser()
// .map { user -> .map { user ->
// val list = val list =
// user.deals?.map { it.estate as EstateEntity }?.toMutableList() user.deals?.map { it.estate as EstateEntity }?.toMutableList()
// ?: mutableListOf() ?: mutableListOf()
// list.addAll(user.estates?.map { it as EstateEntity } ?: arrayListOf()) list.addAll(user.estates?.map { it as EstateEntity } ?: arrayListOf())
// list list
// } }
// .flatMapIterable { it } .flatMapIterable { it }
// .toFlowable(BackpressureStrategy.BUFFER) .toFlowable(BackpressureStrategy.BUFFER)
// .parallel(4) .parallel(4)
// .runOn(Schedulers.io()) .runOn(Schedulers.io())
// .flatMap { planContract.getPlanTypes(it.id) } .flatMap{
planContract.getPlanTypes(it.id)
.map { plantypes -> plantypes.flatMap{ plan -> plan.featuresVariants} }
.toFlowable(BackpressureStrategy.BUFFER)
}
.sequential()
.toList()
.toObservable()
.map { it.flatten() }
.doOnNext { Timber.d(" plaanzz: $it") }
.map { list ->
list.sumBy{ if (planContract.getPlanFile(it).exists()) 0 else 1 }
}
......
...@@ -155,6 +155,7 @@ class SettingsScreenController : ...@@ -155,6 +155,7 @@ class SettingsScreenController :
is SettingsScreenViewState.SomeError -> render(viewState) is SettingsScreenViewState.SomeError -> render(viewState)
is SettingsScreenViewState.SignOut -> render(viewState) is SettingsScreenViewState.SignOut -> render(viewState)
is SettingsScreenViewState.OnCacheDeleting -> render(viewState) is SettingsScreenViewState.OnCacheDeleting -> render(viewState)
is SettingsScreenViewState.OnPlanTypesPrefetch -> render(viewState)
is SettingsScreenViewState.LoadCachInfo -> render(viewState) is SettingsScreenViewState.LoadCachInfo -> render(viewState)
is SettingsScreenViewState.LoadSubscriptions -> render(viewState) is SettingsScreenViewState.LoadSubscriptions -> render(viewState)
is SettingsScreenViewState.SubscriptionStatus -> render(viewState) is SettingsScreenViewState.SubscriptionStatus -> render(viewState)
...@@ -179,6 +180,14 @@ class SettingsScreenController : ...@@ -179,6 +180,14 @@ class SettingsScreenController :
) )
} }
private fun render(viewState: SettingsScreenViewState.OnPlanTypesPrefetch) {
flatDownloaderTitle.text =
resources?.getString(
R.string.download_all_plan_types_settings_with_sizes
, viewState.size.bytesToSize()
)
}
private fun render(viewState: SettingsScreenViewState.LoadSubscriptions){ private fun render(viewState: SettingsScreenViewState.LoadSubscriptions){
(pushRecycler.adapter as PushListAdapter).setItems(viewState.list) (pushRecycler.adapter as PushListAdapter).setItems(viewState.list)
} }
......
...@@ -41,6 +41,10 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -41,6 +41,10 @@ class SettingsScreenPresenter @Inject constructor(
val fetchToursSize = interactor.fetchToursSizes() val fetchToursSize = interactor.fetchToursSizes()
.map { SettingsScreenViewState.OnSizePrefetch(it) } .map { SettingsScreenViewState.OnSizePrefetch(it) }
val fetchPlansSize = interactor.fetchPlanTypesSizes()
.map { it*1024L }
.map { SettingsScreenViewState.OnPlanTypesPrefetch(it) }
val onDownloadTours = intent(SettingsScreen::downloadAllTours) val onDownloadTours = intent(SettingsScreen::downloadAllTours)
.flatMap { interactor.startToursDownloading() .flatMap { interactor.startToursDownloading()
.andThen(Observable.just(SettingsScreenViewState.Idle())) .andThen(Observable.just(SettingsScreenViewState.Idle()))
...@@ -116,6 +120,7 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -116,6 +120,7 @@ class SettingsScreenPresenter @Inject constructor(
val state = Observable.mergeDelayError( val state = Observable.mergeDelayError(
arrayListOf( arrayListOf(
restoreStateObservable, restoreStateObservable,
fetchPlansSize,
fetchSettings, fetchSettings,
onSignOut, onSignOut,
onClearCache, onClearCache,
......
...@@ -19,6 +19,7 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() { ...@@ -19,6 +19,7 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class SignOut() : SettingsScreenViewState() class SignOut() : SettingsScreenViewState()
class OnCacheDeleting(val progress:Float) : SettingsScreenViewState() class OnCacheDeleting(val progress:Float) : SettingsScreenViewState()
class OnSizePrefetch(val size:Long) : SettingsScreenViewState() class OnSizePrefetch(val size:Long) : SettingsScreenViewState()
class OnPlanTypesPrefetch(val size:Long) : SettingsScreenViewState()
class LoadSubscriptions(val list:List<TitledSubscriptionModel>) : SettingsScreenViewState() class LoadSubscriptions(val list:List<TitledSubscriptionModel>) : SettingsScreenViewState()
class LoadCachInfo(val list: List<CachedDataModel>) : SettingsScreenViewState() class LoadCachInfo(val list: List<CachedDataModel>) : SettingsScreenViewState()
class SubscriptionStatus(val subId:Int,val subState: Boolean) : SettingsScreenViewState() class SubscriptionStatus(val subId:Int,val subState: Boolean) : SettingsScreenViewState()
......
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