mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
Several reader fixes
This commit is contained in:
@@ -6,16 +6,12 @@ import java.net.URLConnection
|
||||
object ImageUtil {
|
||||
|
||||
fun isImage(name: String, openStream: (() -> InputStream)? = null): Boolean {
|
||||
try {
|
||||
val guessedMime = URLConnection.guessContentTypeFromName(name)
|
||||
if (guessedMime.startsWith("image/")) {
|
||||
return true
|
||||
}
|
||||
val contentType = try {
|
||||
URLConnection.guessContentTypeFromName(name)
|
||||
} catch (e: Exception) {
|
||||
/* Ignore error */
|
||||
}
|
||||
|
||||
return openStream?.let { findImageType(it) } != null
|
||||
null
|
||||
} ?: openStream?.let { findImageType(it)?.mime }
|
||||
return contentType?.startsWith("image/") ?: false
|
||||
}
|
||||
|
||||
fun findImageType(openStream: () -> InputStream): ImageType? {
|
||||
|
||||
Reference in New Issue
Block a user