mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +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
|
||||
if (curPath != mToBeDeleted && curPath != mBeingDeleted) {
|
||||
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)
|
||||
continue
|
||||
|
||||
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
||||
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))
|
||||
} else {
|
||||
invalidFiles.add(file)
|
||||
}
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
|
|
@ -50,18 +50,19 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
|||
do {
|
||||
val fullPath = cursor.getString(pathIndex) ?: continue
|
||||
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)
|
||||
continue
|
||||
}
|
||||
|
||||
val parentDir = file.parent
|
||||
if (directories.containsKey(parentDir)) {
|
||||
val directory: Directory = directories[parentDir]!!
|
||||
val newImageCnt = directory.mediaCnt + 1
|
||||
directory.mediaCnt = newImageCnt
|
||||
directory.addSize(file.length())
|
||||
directory.addSize(size)
|
||||
} else if (!mToBeDeleted.contains(parentDir)) {
|
||||
var dirName = context.getHumanizedFilename(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 size = cursor.getLongValue(MediaStore.Images.Media.SIZE)
|
||||
directories.put(parentDir, Directory(parentDir, fullPath, dirName, 1, timestamp, size))
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
|
|
|
@ -49,17 +49,20 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
|
|||
val curPath = cursor.getString(pathIndex) ?: continue
|
||||
if (!mToBeDeleted.contains(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)
|
||||
continue
|
||||
|
||||
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
|
||||
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))
|
||||
} else {
|
||||
invalidFiles.add(file)
|
||||
}
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue