clear weekly views before adding them

This commit is contained in:
tibbi 2017-01-18 22:47:33 +01:00
parent a0cc3910e5
commit b8d71620aa
1 changed files with 6 additions and 1 deletions

View File

@ -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
}