All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.seiko.imageloader.model.ExtraData.kt Maven / Gradle / Ivy

There is a newer version: 1.8.3
Show newest version
package com.seiko.imageloader.model

typealias ExtraData = Map
typealias ExtraDataBuilder = MutableMap

val EmptyExtraData get() = emptyMap()

private const val KEY_MIME_TYPE = "KEY_MIME_TYPE"
private const val KEY_META_DATA = "KEY_META_DATA"

fun extraData(block: ExtraDataBuilder.() -> Unit) = buildMap(block)

fun ExtraDataBuilder.mimeType(type: String?) {
    if (!type.isNullOrEmpty()) set(KEY_MIME_TYPE, type)
}

val ExtraData.mimeType: String?
    get() = get(KEY_MIME_TYPE) as? String

internal fun ExtraDataBuilder.metadata(metadata: Any?) {
    if (metadata != null) set(KEY_META_DATA, metadata)
}

internal inline val ExtraData.metadata: Any?
    get() = get(KEY_META_DATA)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy