-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2d881f
commit 1afd2d3
Showing
9 changed files
with
55 additions
and
106 deletions.
There are no files selected for viewing
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
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
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
30 changes: 6 additions & 24 deletions
30
app/src/main/kotlin/org/koitharu/kotatsu/local/data/ImageFileFilter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
package org.koitharu.kotatsu.local.data | ||
|
||
import java.io.File | ||
import java.io.FileFilter | ||
import java.io.FilenameFilter | ||
import java.util.Locale | ||
import java.util.zip.ZipEntry | ||
|
||
class ImageFileFilter : FilenameFilter, FileFilter { | ||
|
||
override fun accept(dir: File, name: String): Boolean { | ||
val ext = name.substringAfterLast('.', "").lowercase(Locale.ROOT) | ||
return isExtensionValid(ext) | ||
} | ||
|
||
override fun accept(pathname: File?): Boolean { | ||
val ext = pathname?.extension?.lowercase(Locale.ROOT) ?: return false | ||
return isExtensionValid(ext) | ||
} | ||
|
||
fun accept(entry: ZipEntry): Boolean { | ||
val ext = entry.name.substringAfterLast('.', "").lowercase(Locale.ROOT) | ||
return isExtensionValid(ext) | ||
} | ||
|
||
fun isExtensionValid(ext: String): Boolean { | ||
return ext == "png" || ext == "jpg" || ext == "jpeg" || ext == "webp" | ||
} | ||
fun hasImageExtension(string: String): Boolean { | ||
val ext = string.substringAfterLast('.', "") | ||
return ext.equals("png", ignoreCase = true) || ext.equals("jpg", ignoreCase = true) | ||
|| ext.equals("jpeg", ignoreCase = true) || ext.equals("webp", ignoreCase = true) | ||
} | ||
|
||
fun hasImageExtension(file: File) = hasImageExtension(file.name) |
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
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
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
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
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