From cd478ea36f2018908968ad825200339b2ba4dc97 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 22 Mar 2020 16:30:46 +0100 Subject: [PATCH] minor cleanup at WeekFragment --- .../calendar/pro/fragments/WeekFragment.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index 20c9d980f..69d9d92c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -54,7 +54,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { private var dimPastEvents = true private var selectedGrid: View? = null private var currentTimeView: ImageView? = null - private var events = ArrayList() private var allDayHolders = ArrayList() private var allDayRows = ArrayList>() private var eventTypeColors = LongSparseArray() @@ -63,7 +62,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { private lateinit var inflater: LayoutInflater private lateinit var mView: View private lateinit var scrollView: MyScrollView - private lateinit var calendar: WeeklyCalendarImpl private lateinit var res: Resources private lateinit var config: Config @@ -76,7 +74,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { dimPastEvents = config.dimPastEvents primaryColor = context!!.getAdjustedPrimaryColor() allDayRows.add(HashSet()) - calendar = WeeklyCalendarImpl(this, context!!) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -131,7 +128,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } fun updateCalendar() { - calendar.updateWeeklyCalendar(weekTimestamp) + WeeklyCalendarImpl(this, context!!).updateWeeklyCalendar(weekTimestamp) } private fun setupDayLabels() { @@ -213,16 +210,15 @@ class WeekFragment : Fragment(), WeeklyCalendar { } lastHash = newHash - this.events = events activity!!.runOnUiThread { if (context != null && activity != null && isAdded) { - addEvents() + addEvents(events) } } } - private fun addEvents() { + private fun addEvents(events: ArrayList) { initGrid() allDayHolders.clear() allDayRows.clear() @@ -235,7 +231,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val fullHeight = res.getDimension(R.dimen.weekly_view_events_height) val minuteHeight = fullHeight / (24 * 60) val minimalHeight = res.getDimension(R.dimen.weekly_view_minimal_event_height).toInt() - val density = Math.round(context!!.resources.displayMetrics.density) + val density = Math.round(res.displayMetrics.density) var hadAllDayEvent = false val replaceDescription = config.replaceDescription