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

plan cache

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