Commit 4a6a88b7 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

plan file name spec

parent 4955bcd8
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.data.repository.file
import android.app.Application
import android.content.Context
import android.os.Environment
import com.biganto.visual.roompark.util.extensions.asInt
import com.google.gson.JsonElement
import dagger.Module
import timber.log.Timber
......@@ -66,18 +67,31 @@ class FileModule @Inject constructor(val context: Application) {
}
companion object {
fun getDirectory(context: Context?, dirType: FileDirectory): File =
File(
context?.filesDir?.absolutePath?.plus(dirType.dir)
?: throw IllegalArgumentException("Context cannot be null!")
)
fun assetsDirectory(context: Context?): String = context?.filesDir?.absolutePath
?: throw IllegalArgumentException("Context cannot be null!")
fun getDirectory(context: Context, dirType: FileDirectory): File =
File(context.filesDir.absolutePath.plus(dirType.dir))
fun assetsDirectory(context: Context): String = context.filesDir.absolutePath
}
sealed class FileDirectory(val dir:String) {
class PlanTypeDir(dir:String = "/estates",childName:String? = null) : FileDirectory(dir.plus("/$childName"))
class PlanTypeDir: FileDirectory{
constructor (dir:String = "/estates",childName:String? = null) : super(dir.plus("/$childName"))
constructor (catalog:String = "/estates"
,estateId: Int
, planId:Int
, furniture:Boolean? = null
, sizes:Boolean? = null
, walls:Boolean? = null
, electric:Boolean? = null
) : super(catalog.plus("/plan").plus("/$estateId").plus("/$planId")
.plus("plan_${planId}_${furniture?:"f${furniture.asInt}"}" +
"_${sizes?:"f${sizes.asInt}"}" +
"_${walls?:"f${walls.asInt}"}" +
"_${electric?:"f${electric.asInt}"}")
.plus(".html"))
}
class ToursDir(dir:String = "/tours",childName:String? = null) : FileDirectory(dir.plus("/childName"))
class FeedsDir(dir:String = "/feeds",childName:String? = null) : FileDirectory(dir.plus("/childName"))
class Albums(dir:String = "/photos",childName:String? = null) : FileDirectory(dir.plus("/childName"))
......
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