minor cleanup at WeekFragment

This commit is contained in:
tibbi 2020-03-22 16:30:46 +01:00
parent 70435de24b
commit cd478ea36f
1 changed files with 4 additions and 8 deletions

View File

@ -54,7 +54,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private var dimPastEvents = true private var dimPastEvents = true
private var selectedGrid: View? = null private var selectedGrid: View? = null
private var currentTimeView: ImageView? = null private var currentTimeView: ImageView? = null
private var events = ArrayList<Event>()
private var allDayHolders = ArrayList<RelativeLayout>() private var allDayHolders = ArrayList<RelativeLayout>()
private var allDayRows = ArrayList<HashSet<Int>>() private var allDayRows = ArrayList<HashSet<Int>>()
private var eventTypeColors = LongSparseArray<Int>() private var eventTypeColors = LongSparseArray<Int>()
@ -63,7 +62,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private lateinit var inflater: LayoutInflater private lateinit var inflater: LayoutInflater
private lateinit var mView: View private lateinit var mView: View
private lateinit var scrollView: MyScrollView private lateinit var scrollView: MyScrollView
private lateinit var calendar: WeeklyCalendarImpl
private lateinit var res: Resources private lateinit var res: Resources
private lateinit var config: Config private lateinit var config: Config
@ -76,7 +74,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
dimPastEvents = config.dimPastEvents dimPastEvents = config.dimPastEvents
primaryColor = context!!.getAdjustedPrimaryColor() primaryColor = context!!.getAdjustedPrimaryColor()
allDayRows.add(HashSet()) allDayRows.add(HashSet())
calendar = WeeklyCalendarImpl(this, context!!)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -131,7 +128,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} }
fun updateCalendar() { fun updateCalendar() {
calendar.updateWeeklyCalendar(weekTimestamp) WeeklyCalendarImpl(this, context!!).updateWeeklyCalendar(weekTimestamp)
} }
private fun setupDayLabels() { private fun setupDayLabels() {
@ -213,16 +210,15 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} }
lastHash = newHash lastHash = newHash
this.events = events
activity!!.runOnUiThread { activity!!.runOnUiThread {
if (context != null && activity != null && isAdded) { if (context != null && activity != null && isAdded) {
addEvents() addEvents(events)
} }
} }
} }
private fun addEvents() { private fun addEvents(events: ArrayList<Event>) {
initGrid() initGrid()
allDayHolders.clear() allDayHolders.clear()
allDayRows.clear() allDayRows.clear()
@ -235,7 +231,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val fullHeight = res.getDimension(R.dimen.weekly_view_events_height) val fullHeight = res.getDimension(R.dimen.weekly_view_events_height)
val minuteHeight = fullHeight / (24 * 60) val minuteHeight = fullHeight / (24 * 60)
val minimalHeight = res.getDimension(R.dimen.weekly_view_minimal_event_height).toInt() 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 var hadAllDayEvent = false
val replaceDescription = config.replaceDescription val replaceDescription = config.replaceDescription