do not show events at the month part of month/day view

This commit is contained in:
tibbi 2021-02-21 18:22:21 +01:00
parent 660582c41d
commit 1742ee5666
4 changed files with 17 additions and 10 deletions

View File

@ -100,8 +100,8 @@ class MonthDayFragment : Fragment(), MonthlyCalendar {
}
private fun updateDays(days: ArrayList<DayMonthly>) {
mHolder.month_day_view_wrapper.updateDays(days) {
(activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
mHolder.month_day_view_wrapper.updateDays(days, false) {
// (activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
}
}

View File

@ -142,7 +142,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
}
private fun updateDays(days: ArrayList<DayMonthly>) {
mHolder.month_view_wrapper.updateDays(days) {
mHolder.month_view_wrapper.updateDays(days, true) {
(activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
}
}

View File

@ -50,6 +50,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
private var dimPastEvents = true
private var highlightWeekends = false
private var isPrintVersion = false
private var isMonthDayView = false
private var allEvents = ArrayList<MonthViewEvent>()
private var bgRectF = RectF()
private var dayLetters = ArrayList<String>()
@ -92,7 +93,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
setupCurrentDayOfWeekIndex()
}
fun updateDays(newDays: ArrayList<DayMonthly>) {
fun updateDays(newDays: ArrayList<DayMonthly>, isMonthDayView: Boolean) {
this.isMonthDayView = isMonthDayView
days = newDays
showWeekNumbers = config.showWeekNumbers
horizontalOffset = if (showWeekNumbers) eventTitleHeight * 2 else 0
@ -129,7 +131,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
dayVerticalOffsets.clear()
measureDaySize(canvas)
if (config.showGrid) {
if (config.showGrid && !isMonthDayView) {
drawGrid(canvas)
}
@ -159,10 +161,12 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
}
}
if (!isMonthDayView) {
for (event in allEvents) {
drawEvent(event, canvas)
}
}
}
private fun drawGrid(canvas: Canvas) {
// vertical lines

View File

@ -17,6 +17,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
private var weekDaysLetterHeight = 0
private var horizontalOffset = 0
private var wereViewsAdded = false
private var isMonthDayView = true
private var days = ArrayList<DayMonthly>()
private var inflater: LayoutInflater
private var monthView: MonthView
@ -36,12 +37,12 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
if (!wereViewsAdded && days.isNotEmpty()) {
measureSizes()
addViews()
monthView.updateDays(days)
monthView.updateDays(days, isMonthDayView)
}
}
}
fun updateDays(newDays: ArrayList<DayMonthly>, callback: ((DayMonthly) -> Unit)? = null) {
fun updateDays(newDays: ArrayList<DayMonthly>, addEvents: Boolean, callback: ((DayMonthly) -> Unit)? = null) {
setupHorizontalOffset()
measureSizes()
dayClickCallback = callback
@ -49,7 +50,9 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
if (dayWidth != 0f && dayHeight != 0f) {
addViews()
}
monthView.updateDays(days)
isMonthDayView = !addEvents
monthView.updateDays(days, isMonthDayView)
}
private fun setupHorizontalOffset() {