store the Last Modified field of FileDirItems directly in the model
This commit is contained in:
parent
8756069f18
commit
87a6f1db3a
3 changed files with 8 additions and 12 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
||||||
propMinSdkVersion = 21
|
propMinSdkVersion = 21
|
||||||
propTargetSdkVersion = propCompileSdkVersion
|
propTargetSdkVersion = propCompileSdkVersion
|
||||||
propVersionCode = 1
|
propVersionCode = 1
|
||||||
propVersionName = '5.13.10'
|
propVersionName = '5.13.11'
|
||||||
kotlin_version = '1.3.31'
|
kotlin_version = '1.3.31'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PropertiesDialog() {
|
||||||
val dateModified = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
val dateModified = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L
|
||||||
updateLastModified(activity, view, dateModified)
|
updateLastModified(activity, view, dateModified)
|
||||||
} else {
|
} else {
|
||||||
updateLastModified(activity, view, fileDirItem.getLastModified())
|
updateLastModified(activity, view, fileDirItem.modified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class PropertiesDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileDirItem.isDirectory) {
|
if (fileDirItem.isDirectory) {
|
||||||
addProperty(R.string.last_modified, fileDirItem.getLastModified().formatDate(activity))
|
addProperty(R.string.last_modified, fileDirItem.modified.formatDate(activity))
|
||||||
} else {
|
} else {
|
||||||
addProperty(R.string.last_modified, "…", R.id.properties_last_modified)
|
addProperty(R.string.last_modified, "…", R.id.properties_last_modified)
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,13 +5,13 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class FileDirItem(val path: String, val name: String = "", var isDirectory: Boolean = false, var children: Int = 0, var size: Long = 0L) :
|
open class FileDirItem(val path: String, val name: String = "", var isDirectory: Boolean = false, var children: Int = 0, var size: Long = 0L, var modified: Long = 0L) :
|
||||||
Comparable<FileDirItem> {
|
Comparable<FileDirItem> {
|
||||||
companion object {
|
companion object {
|
||||||
var sorting = 0
|
var sorting = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString() = "FileDirItem(path=$path, name=$name, isDirectory=$isDirectory, children=$children, size=$size)"
|
override fun toString() = "FileDirItem(path=$path, name=$name, isDirectory=$isDirectory, children=$children, size=$size, modified=$modified)"
|
||||||
|
|
||||||
override fun compareTo(other: FileDirItem): Int {
|
override fun compareTo(other: FileDirItem): Int {
|
||||||
return if (isDirectory && !other.isDirectory) {
|
return if (isDirectory && !other.isDirectory) {
|
||||||
|
@ -28,11 +28,9 @@ open class FileDirItem(val path: String, val name: String = "", var isDirectory:
|
||||||
else -> -1
|
else -> -1
|
||||||
}
|
}
|
||||||
sorting and SORT_BY_DATE_MODIFIED != 0 -> {
|
sorting and SORT_BY_DATE_MODIFIED != 0 -> {
|
||||||
val file = File(path)
|
|
||||||
val otherFile = File(other.path)
|
|
||||||
result = when {
|
result = when {
|
||||||
file.lastModified() == otherFile.lastModified() -> 0
|
modified == other.modified -> 0
|
||||||
file.lastModified() > otherFile.lastModified() -> 1
|
modified > other.modified -> 1
|
||||||
else -> -1
|
else -> -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +50,7 @@ open class FileDirItem(val path: String, val name: String = "", var isDirectory:
|
||||||
|
|
||||||
fun getBubbleText(context: Context) = when {
|
fun getBubbleText(context: Context) = when {
|
||||||
sorting and SORT_BY_SIZE != 0 -> size.formatSize()
|
sorting and SORT_BY_SIZE != 0 -> size.formatSize()
|
||||||
sorting and SORT_BY_DATE_MODIFIED != 0 -> File(path).lastModified().formatDate(context)
|
sorting and SORT_BY_DATE_MODIFIED != 0 -> modified.formatDate(context)
|
||||||
sorting and SORT_BY_EXTENSION != 0 -> getExtension().toLowerCase()
|
sorting and SORT_BY_EXTENSION != 0 -> getExtension().toLowerCase()
|
||||||
else -> name
|
else -> name
|
||||||
}
|
}
|
||||||
|
@ -63,8 +61,6 @@ open class FileDirItem(val path: String, val name: String = "", var isDirectory:
|
||||||
|
|
||||||
fun getDirectChildrenCount(countHiddenItems: Boolean) = File(path).getDirectChildrenCount(countHiddenItems)
|
fun getDirectChildrenCount(countHiddenItems: Boolean) = File(path).getDirectChildrenCount(countHiddenItems)
|
||||||
|
|
||||||
fun getLastModified() = File(path).lastModified()
|
|
||||||
|
|
||||||
fun getParentPath() = path.getParentPath()
|
fun getParentPath() = path.getParentPath()
|
||||||
|
|
||||||
fun getDuration() = path.getDuration()
|
fun getDuration() = path.getDuration()
|
||||||
|
|
Loading…
Reference in a new issue