add helper functions for checking file type
This commit is contained in:
parent
387082ece7
commit
0227d02da9
2 changed files with 7 additions and 6 deletions
|
@ -4,6 +4,11 @@ import android.graphics.BitmapFactory
|
|||
import android.media.MediaMetadataRetriever
|
||||
import java.io.File
|
||||
|
||||
fun File.isImageVideoGif() = absolutePath.isImageFast() || absolutePath.isVideoFast() || absolutePath.isGif()
|
||||
fun File.isGif() = absolutePath.endsWith(".gif", true)
|
||||
fun File.isVideoFast() = absolutePath.videoExtensions.any { absolutePath.endsWith(".$it", true) }
|
||||
fun File.isImageFast() = absolutePath.photoExtensions.any { absolutePath.endsWith(".$it", true) }
|
||||
|
||||
fun File.isImageSlow() = absolutePath.isImageFast() || getMimeType().startsWith("image")
|
||||
fun File.isVideoSlow() = absolutePath.isVideoFast() || getMimeType().startsWith("video")
|
||||
fun File.isAudioSlow() = getMimeType().startsWith("audio")
|
||||
|
|
|
@ -32,11 +32,7 @@ fun String.isImageVideoGif() = isImageFast() || isVideoFast() || isGif()
|
|||
fun String.isGif() = endsWith(".gif", true)
|
||||
|
||||
// fast extension check, not guaranteed to be accurate
|
||||
fun String.isVideoFast(): Boolean {
|
||||
return videoExtensions.any { endsWith(".$it", true) }
|
||||
}
|
||||
fun String.isVideoFast() = videoExtensions.any { endsWith(".$it", true) }
|
||||
|
||||
// fast extension check, not guaranteed to be accurate
|
||||
fun String.isImageFast(): Boolean {
|
||||
return photoExtensions.any { endsWith(".$it", true) }
|
||||
}
|
||||
fun String.isImageFast() = photoExtensions.any { endsWith(".$it", true) }
|
||||
|
|
Loading…
Reference in a new issue