add a helper function to determine if the file is an image

This commit is contained in:
tibbi
2016-10-16 15:58:44 +02:00
parent 424ca7dfb5
commit fd00b26f9b
2 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,7 @@
package com.simplemobiletools.filepicker.models
import android.graphics.BitmapFactory
class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) :
Comparable<FileDirItem> {
@ -16,4 +18,10 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
override fun toString(): String {
return "FileDirItem{name=$name, isDirectory=$isDirectory, path=$path, children=$children, size=$size}"
}
fun isImage(): Boolean {
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
return options.outWidth !== -1 && options.outHeight !== -1
}
}