From b8d71620aa9220399635b02a66b39a440ea450f4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 18 Jan 2017 22:47:33 +0100 Subject: [PATCH] clear weekly views before adding them --- .../simplemobiletools/calendar/fragments/WeekFragment.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt index b1fc3df27..22f4b53dd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -87,11 +87,14 @@ class WeekFragment : Fragment(), WeeklyCalendar { val minuteHeight = fullHeight / (24 * 60) val eventColor = context.config.primaryColor val sideMargin = mRes.displayMetrics.density.toInt() + (0..6).map { getColumnWithId(it) } + .forEach { activity.runOnUiThread { it.removeAllViews() } } + for (event in events) { val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS) val dayOfWeek = startDateTime.dayOfWeek - if (context.config.isSundayFirst) 0 else 1 - val layout = mView.findViewById(mRes.getIdentifier("week_column_$dayOfWeek", "id", context.packageName)) as LinearLayout + val layout = getColumnWithId(dayOfWeek) val startMinutes = startDateTime.minuteOfDay val duration = endDateTime.minuteOfDay - startMinutes @@ -110,6 +113,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun getColumnWithId(id: Int) = mView.findViewById(mRes.getIdentifier("week_column_$id", "id", context.packageName)) as LinearLayout + fun setListener(listener: WeekScrollListener) { mListener = listener }