check the filesize only after checking the file type

This commit is contained in:
tibbi 2017-09-11 21:34:15 +02:00
parent ffcd632bad
commit 624c0e2d08
1 changed files with 13 additions and 13 deletions

View File

@ -81,14 +81,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
do {
try {
val path = cur.getStringValue(MediaStore.Images.Media.DATA)
var size = cur.getLongValue(MediaStore.Images.Media.SIZE)
if (size == 0L) {
size = File(path).length()
}
if (size <= 0L) {
continue
}
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""
if (filename.isEmpty())
@ -113,6 +105,15 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
if (!showHidden && filename.startsWith('.'))
continue
var size = cur.getLongValue(MediaStore.Images.Media.SIZE)
val file = File(path)
if (size == 0L) {
size = file.length()
}
if (size <= 0L)
continue
var isExcluded = false
excludedFolders.forEach {
if (path.startsWith(it)) {
@ -168,11 +169,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) {
val files = File(folder).listFiles() ?: return
for (file in files) {
val size = file.length()
if (size <= 0L) {
continue
}
val filename = file.name
val isImage = filename.isImageFast()
val isVideo = if (isImage) false else filename.isVideoFast()
@ -190,6 +186,10 @@ private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPick
if (isGif && filterMedia and GIFS == 0)
continue
val size = file.length()
if (size <= 0L)
continue
val dateTaken = file.lastModified()
val dateModified = file.lastModified()