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

desktopMain.com.seiko.imageloader.component.mapper.FileUriMapper.kt Maven / Gradle / Ivy

There is a newer version: 1.9.0
Show newest version
package com.seiko.imageloader.component.mapper

import com.eygraber.uri.Uri
import com.seiko.imageloader.request.Options
import com.seiko.imageloader.util.firstPathSegment
import java.io.File

class FileUriMapper : Mapper {
    override fun map(data: Any, options: Options): File? {
        if (data !is Uri) return null
        if (!isApplicable(data)) return null
        return File(data.path)
    }

    private fun isApplicable(data: Uri): Boolean {
        return data.scheme.let { it == null || it == "file" } &&
            data.path.orEmpty().startsWith('/') && data.firstPathSegment != null
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy