Commit 48c17059 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix childs naming

parent b6bf36b6
package com.biganto.visual.roompark.data.data_provider
import android.app.Application
import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.domain.contract.FilesContract
import javax.inject.Inject
import kotlin.reflect.full.primaryConstructor
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
......@@ -14,10 +16,15 @@ import javax.inject.Inject
class FilesContractModule @Inject constructor(
private val files: FileModule,
private val api: IRoomParkApi,
private val db: IDb
private val db: IDb,
private val context: Application
): FilesContract {
inline fun <reified T:FileModule.FileDirectory> getDirectory(): T? =
T::class.primaryConstructor?.call()
fun getPlansSize() = getDirectorySize<>()
}
......@@ -73,9 +73,13 @@ class FileModule @Inject constructor(val context: Application) {
fun assetsDirectory(context: Context): String = context.filesDir.absolutePath
}
sealed class FileDirectory(val dir:String) {
class PlanTypeDir: FileDirectory{
constructor (dir:String = "/estates",childName:String? = null) : super(dir.plus("/$childName"))
constructor (dir:String = "/estates",childName:String? = null)
:super(dir.plus(childName.slashed()))
constructor (catalog:String = "/estates"
,estateId: Int
......@@ -93,8 +97,15 @@ class FileModule @Inject constructor(val context: Application) {
.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"))
class ToursDir(dir:String = "/tours",childName:String? = null)
: FileDirectory(dir.plus(childName.slashed()))
class FeedsDir(dir:String = "/feeds",childName:String? = null)
: FileDirectory(dir.plus(childName.slashed()))
class Albums(dir:String = "/photos",childName:String? = null)
: FileDirectory(dir.plus(childName.slashed()))
}
}
private fun String?.slashed(): String {
return this?.padStart(this.length+1,'/')?:""
}
\ No newline at end of file
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