From e5e8c2a462e0a3aca083c4835c0390c16f633e2b Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 19 Dec 2018 19:36:18 +0100 Subject: [PATCH] optimize week start timestamp fetching --- .../calendar/pro/fragments/WeekFragmentsHolder.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index c911c3963..ac9ff0cf7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -97,8 +97,10 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { private fun getWeekTimestamps(targetSeconds: Long): List { val weekTSs = ArrayList(PREFILLED_WEEKS) - for (i in -PREFILLED_WEEKS / 2..PREFILLED_WEEKS / 2) { - weekTSs.add(Formatter.getDateTimeFromTS(targetSeconds).plusWeeks(i).seconds()) + var currWeekTS = targetSeconds - (PREFILLED_WEEKS / 2 * WEEK_SECONDS) + for (i in 0 until PREFILLED_WEEKS) { + weekTSs.add(currWeekTS) + currWeekTS += WEEK_SECONDS } return weekTSs }