-
-
Save carstenhag/230f203b58dab33a8155a850bea06a6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:Import( | |
"../app/src/main/java/com/bmw/chargenow/business/services/whitelabel/WhiteLabelTheme.kt", | |
"../app/src/main/java/com/bmw/chargenow/data/whitelabel/WhiteLabelThemeEntity.kt", | |
"../app/src/main/java/com/bmw/chargenow/data/whitelabel/WhiteLabelThemeImagesEntity.kt", | |
) | |
import kotlinx.serialization.ExperimentalSerializationApi | |
import kotlinx.serialization.json.Json | |
import java.io.File | |
import java.io.FileFilter | |
// Copied from AppModule.kt's provideJson() | |
@OptIn(ExperimentalSerializationApi::class) | |
val json = Json { | |
ignoreUnknownKeys = true | |
encodeDefaults = true // for requests we want default values to be included | |
isLenient = true // quoted booleans and unquoted strings are allowed | |
coerceInputValues = true // coerce unknown enum values to default | |
explicitNulls = false | |
} | |
val basePath = "../app/src/brandFleets/res/raw/" | |
val filePrefix = "whitelabeltheme_" | |
val dir = File(basePath) | |
val fileFilter = FileFilter { file -> | |
file.isFile && file.name.startsWith(filePrefix) | |
} | |
val files = dir.listFiles(fileFilter)?.toList() ?: listOf() | |
files.forEach { file -> | |
val jsonString = file.readText() | |
val entity = json.decodeFromString<WhiteLabelThemeEntity>(jsonString) // --> Unresolved reference: WhiteLabelThemeEntity | |
val theme = entity.toBusinessObject() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment