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 ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.data.repository.file
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
import com.biganto.visual.roompark.util.extensions.asInt
import com.google.gson.JsonElement import com.google.gson.JsonElement
import dagger.Module import dagger.Module
import timber.log.Timber import timber.log.Timber
...@@ -66,18 +67,31 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -66,18 +67,31 @@ class FileModule @Inject constructor(val context: Application) {
} }
companion object { companion object {
fun getDirectory(context: Context?, dirType: FileDirectory): File = fun getDirectory(context: Context, dirType: FileDirectory): File =
File( File(context.filesDir.absolutePath.plus(dirType.dir))
context?.filesDir?.absolutePath?.plus(dirType.dir)
?: throw IllegalArgumentException("Context cannot be null!") fun assetsDirectory(context: Context): String = context.filesDir.absolutePath
)
fun assetsDirectory(context: Context?): String = context?.filesDir?.absolutePath
?: throw IllegalArgumentException("Context cannot be null!")
} }
sealed class FileDirectory(val dir:String) { 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 ToursDir(dir:String = "/tours",childName:String? = null) : FileDirectory(dir.plus("/childName"))
class FeedsDir(dir:String = "/feeds",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")) 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