mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
some more performance improvements
This commit is contained in:
parent
c9c5f549be
commit
bbdafef491
3 changed files with 26 additions and 20 deletions
|
@ -325,17 +325,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val curPath = cursor.getString(pathIndex) ?: continue
|
val curPath = cursor.getString(pathIndex) ?: continue
|
||||||
if (curPath != mToBeDeleted && curPath != mBeingDeleted) {
|
if (curPath != mToBeDeleted && curPath != mBeingDeleted) {
|
||||||
val file = File(curPath)
|
val file = File(curPath)
|
||||||
if (file.exists()) {
|
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
||||||
|
|
||||||
|
if (size == 0L) {
|
||||||
|
invalidFiles.add(file)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// exclude images of subdirectories
|
||||||
if (file.parent != mDirectory)
|
if (file.parent != mDirectory)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
||||||
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
||||||
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
|
||||||
media.add(Medium(name, curPath, i == 1, timestamp, size))
|
media.add(Medium(name, curPath, i == 1, timestamp, size))
|
||||||
} else {
|
|
||||||
invalidFiles.add(file)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,18 +50,19 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
do {
|
do {
|
||||||
val fullPath = cursor.getString(pathIndex) ?: continue
|
val fullPath = cursor.getString(pathIndex) ?: continue
|
||||||
val file = File(fullPath)
|
val file = File(fullPath)
|
||||||
val parentDir = file.parent
|
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
||||||
|
|
||||||
if (!file.exists() || file.length() == 0L) {
|
if (size == 0L) {
|
||||||
invalidFiles.add(file)
|
invalidFiles.add(file)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val parentDir = file.parent
|
||||||
if (directories.containsKey(parentDir)) {
|
if (directories.containsKey(parentDir)) {
|
||||||
val directory: Directory = directories[parentDir]!!
|
val directory: Directory = directories[parentDir]!!
|
||||||
val newImageCnt = directory.mediaCnt + 1
|
val newImageCnt = directory.mediaCnt + 1
|
||||||
directory.mediaCnt = newImageCnt
|
directory.mediaCnt = newImageCnt
|
||||||
directory.addSize(file.length())
|
directory.addSize(size)
|
||||||
} else if (!mToBeDeleted.contains(parentDir)) {
|
} else if (!mToBeDeleted.contains(parentDir)) {
|
||||||
var dirName = context.getHumanizedFilename(parentDir)
|
var dirName = context.getHumanizedFilename(parentDir)
|
||||||
if (mConfig.getIsFolderHidden(parentDir)) {
|
if (mConfig.getIsFolderHidden(parentDir)) {
|
||||||
|
@ -69,7 +70,6 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
}
|
}
|
||||||
|
|
||||||
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
||||||
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
|
||||||
directories.put(parentDir, Directory(parentDir, fullPath, dirName, 1, timestamp, size))
|
directories.put(parentDir, Directory(parentDir, fullPath, dirName, 1, timestamp, size))
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
|
|
|
@ -49,17 +49,20 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
|
||||||
val curPath = cursor.getString(pathIndex) ?: continue
|
val curPath = cursor.getString(pathIndex) ?: continue
|
||||||
if (!mToBeDeleted.contains(curPath)) {
|
if (!mToBeDeleted.contains(curPath)) {
|
||||||
val file = File(curPath)
|
val file = File(curPath)
|
||||||
if (file.exists()) {
|
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
||||||
|
|
||||||
|
if (size == 0L) {
|
||||||
|
invalidFiles.add(file)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// exclude images of subdirectories
|
||||||
if (file.parent != mPath)
|
if (file.parent != mPath)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
||||||
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
val timestamp = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED)
|
||||||
val size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
|
||||||
media.add(Medium(name, curPath, i == 1, timestamp, size))
|
media.add(Medium(name, curPath, i == 1, timestamp, size))
|
||||||
} else {
|
|
||||||
invalidFiles.add(file)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue