Commit 450c1003 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

plan cache

parent 55e0a43e
...@@ -122,20 +122,34 @@ class EstateRepository @Inject constructor( ...@@ -122,20 +122,34 @@ class EstateRepository @Inject constructor(
,walls?:false ,walls?:false
,electric?:false) ,electric?:false)
.map{ .map{
val sFile = FileModule.getDirectory(file.context val sFile = getPlanFile(
,FileModule.FileDirectory.PlanTypeDir(
estateId = estateId, estateId = estateId,
planId = planId, planId = planId,
furniture = furniture, furniture = furniture,
walls = walls, walls = walls,
sizes = sizes, sizes = sizes,
electric = electric electric = electric)
))
file.saveFileToDisk(sFile,it) file.saveFileToDisk(sFile,it)
sFile.path sFile.path
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
private fun getPlanFile(estateId: Int
, planId:Int
, furniture:Boolean? = null
, sizes:Boolean? = null
, walls:Boolean? = null
, electric:Boolean? = null)
= FileModule.getDirectory(file.context
,FileModule.FileDirectory.PlanTypeDir(
estateId = estateId,
planId = planId,
furniture = furniture,
walls = walls,
sizes = sizes,
electric = electric
))
override fun getEmptyPlan(estateId: Int override fun getEmptyPlan(estateId: Int
,planId:Int): Observable<String> = ,planId:Int): Observable<String> =
...@@ -149,17 +163,22 @@ class EstateRepository @Inject constructor( ...@@ -149,17 +163,22 @@ class EstateRepository @Inject constructor(
, sizes:Boolean? , sizes:Boolean?
, walls:Boolean? , walls:Boolean?
, electric:Boolean?): Observable<String> = , electric:Boolean?): Observable<String> =
Observable.mergeDelayError( Observable.fromCallable { getPlanFile(
arrayListOf( estateId = estateId,
getPlanApi(estateId planId = planId,
,planId furniture = furniture,
, furniture walls = walls,
, sizes sizes = sizes,
, walls electric = electric) }.switchMap {
, electric if (it.exists()) Observable.just(it.path)
) else getPlanApi(estateId
,planId
, furniture
, sizes
, walls
, electric
) )
) }
// fun getPlanRequestString(estateId: Int // fun getPlanRequestString(estateId: Int
......
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