rewrite getFormat the kotlin way (#5930)

This commit is contained in:
Aria Moradi 2021-09-18 23:45:38 +04:30 committed by GitHub
parent fce3cd00a1
commit 3664195c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,17 +272,17 @@ class LocalSource(private val context: Context) : CatalogueSource {
}
private fun getFormat(file: File): Format {
val extension = file.extension
return if (file.isDirectory) {
Format.Directory(file)
} else if (extension.equals("zip", true) || extension.equals("cbz", true)) {
Format.Zip(file)
} else if (extension.equals("rar", true) || extension.equals("cbr", true)) {
Format.Rar(file)
} else if (extension.equals("epub", true)) {
Format.Epub(file)
} else {
throw Exception(context.getString(R.string.local_invalid_format))
return file.run {
when {
isDirectory -> Format.Directory(file)
extension.equals("zip", true) -> Format.Zip(file)
extension.equals("cbz", true) -> Format.Zip(file)
extension.equals("rar", true) -> Format.Rar(file)
extension.equals("cbr", true) -> Format.Rar(file)
extension.equals("epub", true) -> Format.Epub(file)
else -> throw Exception("Invalid chapter format")
}
}
}