fixing some rounding errors at the weekly view drawing

This commit is contained in:
tibbi 2020-03-23 20:27:28 +01:00
parent ea7f027b2a
commit 5666357d9f
2 changed files with 7 additions and 5 deletions

View File

@ -259,10 +259,12 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private fun updateViewScale() {
rowHeight = context!!.getWeeklyViewItemHeight()
listener?.updateRowHeight(rowHeight.toInt())
val fullHeight = Math.max(rowHeight.toInt() * 24, scrollView.height + context!!.resources.getDimension(R.dimen.one_dp).toInt())
val oneDp = context!!.resources.getDimension(R.dimen.one_dp).toInt()
val fullHeight = Math.max(rowHeight.toInt() * 24, scrollView.height + oneDp)
mView.week_horizontal_grid_holder.layoutParams.height = fullHeight
mView.week_events_columns_holder.layoutParams.height = fullHeight
listener?.updateRowHeight(rowHeight.toInt())
addEvents(currEvents)
}
@ -276,8 +278,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
addNewLine()
val fullHeight = rowHeight * 24
val minuteHeight = fullHeight / (24 * 60)
val minuteHeight = rowHeight / 60
val minimalHeight = res.getDimension(R.dimen.weekly_view_minimal_event_height).toInt()
val density = Math.round(res.displayMetrics.density)

View File

@ -6,6 +6,7 @@ import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.getWeeklyViewItemHeight
class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
private val ROWS_CNT = 24
@ -20,7 +21,7 @@ class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
val rowHeight = height / ROWS_CNT.toFloat()
val rowHeight = context.getWeeklyViewItemHeight()
for (i in 0 until ROWS_CNT) {
val y = rowHeight * i.toFloat()
canvas.drawLine(0f, y, width.toFloat(), y, paint)