mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
obtain the start of the day TS at grouping by date taken and last modified
This commit is contained in:
parent
9eedf64c1b
commit
e3fde0a6eb
1 changed files with 15 additions and 2 deletions
|
@ -13,6 +13,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_PATH
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
||||||
import com.simplemobiletools.gallery.helpers.*
|
import com.simplemobiletools.gallery.helpers.*
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
@Entity(tableName = "media", indices = [(Index(value = "full_path", unique = true))])
|
@Entity(tableName = "media", indices = [(Index(value = "full_path", unique = true))])
|
||||||
data class Medium(
|
data class Medium(
|
||||||
|
@ -48,12 +49,24 @@ data class Medium(
|
||||||
|
|
||||||
fun getGroupingKey(groupBy: Int): String {
|
fun getGroupingKey(groupBy: Int): String {
|
||||||
return when {
|
return when {
|
||||||
groupBy and GROUP_BY_LAST_MODIFIED != 0 -> modified.toString()
|
groupBy and GROUP_BY_LAST_MODIFIED != 0 -> getDayStartTS(modified)
|
||||||
groupBy and GROUP_BY_DATE_TAKEN != 0 -> taken.toString()
|
groupBy and GROUP_BY_DATE_TAKEN != 0 -> getDayStartTS(taken)
|
||||||
groupBy and GROUP_BY_FILE_TYPE != 0 -> type.toString()
|
groupBy and GROUP_BY_FILE_TYPE != 0 -> type.toString()
|
||||||
groupBy and GROUP_BY_EXTENSION != 0 -> name.getFilenameExtension().toLowerCase()
|
groupBy and GROUP_BY_EXTENSION != 0 -> name.getFilenameExtension().toLowerCase()
|
||||||
groupBy and GROUP_BY_FOLDER != 0 -> parentPath
|
groupBy and GROUP_BY_FOLDER != 0 -> parentPath
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDayStartTS(ts: Long): String {
|
||||||
|
val calendar = Calendar.getInstance(Locale.ENGLISH).apply {
|
||||||
|
timeInMillis = ts
|
||||||
|
set(Calendar.HOUR_OF_DAY, 0)
|
||||||
|
set(Calendar.MINUTE, 0)
|
||||||
|
set(Calendar.SECOND, 0)
|
||||||
|
set(Calendar.MILLISECOND, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return calendar.timeInMillis.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue