check the filesize only after checking the file type
This commit is contained in:
parent
ffcd632bad
commit
624c0e2d08
1 changed files with 13 additions and 13 deletions
|
@ -81,14 +81,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
val path = cur.getStringValue(MediaStore.Images.Media.DATA)
|
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) ?: ""
|
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
|
@ -113,6 +105,15 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
|
||||||
if (!showHidden && filename.startsWith('.'))
|
if (!showHidden && filename.startsWith('.'))
|
||||||
continue
|
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
|
var isExcluded = false
|
||||||
excludedFolders.forEach {
|
excludedFolders.forEach {
|
||||||
if (path.startsWith(it)) {
|
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) {
|
private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) {
|
||||||
val files = File(folder).listFiles() ?: return
|
val files = File(folder).listFiles() ?: return
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
val size = file.length()
|
|
||||||
if (size <= 0L) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
val filename = file.name
|
val filename = file.name
|
||||||
val isImage = filename.isImageFast()
|
val isImage = filename.isImageFast()
|
||||||
val isVideo = if (isImage) false else filename.isVideoFast()
|
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)
|
if (isGif && filterMedia and GIFS == 0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
val size = file.length()
|
||||||
|
if (size <= 0L)
|
||||||
|
continue
|
||||||
|
|
||||||
val dateTaken = file.lastModified()
|
val dateTaken = file.lastModified()
|
||||||
val dateModified = file.lastModified()
|
val dateModified = file.lastModified()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue