Fixed logs being bugged down by unreliable code

This commit is contained in:
Viktor De Pasquale 2019-05-09 17:38:13 +02:00
parent e79e744e08
commit a6e7680212

View File

@ -33,22 +33,8 @@ class LogRepository(
private fun List<MagiskLog>.wrap(): List<WrappedMagiskLog> { private fun List<MagiskLog>.wrap(): List<WrappedMagiskLog> {
val day = TimeUnit.DAYS.toMillis(1) val day = TimeUnit.DAYS.toMillis(1)
var currentDay = firstOrNull()?.date?.time ?: return listOf() return groupBy { it.date.time / day }
var tempList = this .map { WrappedMagiskLog(it.key * day, it.value) }
val outList = mutableListOf<WrappedMagiskLog>()
while (tempList.isNotEmpty()) {
val logsGivenDay = takeWhile { it.date.time / day == currentDay / day }
currentDay = tempList.firstOrNull()?.date?.time ?: currentDay + day
if (logsGivenDay.isEmpty())
continue
outList.add(WrappedMagiskLog(currentDay / day * day, logsGivenDay))
tempList = tempList.subList(logsGivenDay.size, tempList.size)
}
return outList
} }