mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
fixing some rounding errors at the weekly view drawing
This commit is contained in:
@@ -259,10 +259,12 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
|
|
||||||
private fun updateViewScale() {
|
private fun updateViewScale() {
|
||||||
rowHeight = context!!.getWeeklyViewItemHeight()
|
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_horizontal_grid_holder.layoutParams.height = fullHeight
|
||||||
mView.week_events_columns_holder.layoutParams.height = fullHeight
|
mView.week_events_columns_holder.layoutParams.height = fullHeight
|
||||||
|
listener?.updateRowHeight(rowHeight.toInt())
|
||||||
addEvents(currEvents)
|
addEvents(currEvents)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,8 +278,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
|
|
||||||
addNewLine()
|
addNewLine()
|
||||||
|
|
||||||
val fullHeight = rowHeight * 24
|
val minuteHeight = rowHeight / 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(res.displayMetrics.density)
|
val density = Math.round(res.displayMetrics.density)
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ import android.graphics.Paint
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.simplemobiletools.calendar.pro.R
|
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) {
|
class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
|
||||||
private val ROWS_CNT = 24
|
private val ROWS_CNT = 24
|
||||||
@@ -20,7 +21,7 @@ class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
val rowHeight = height / ROWS_CNT.toFloat()
|
val rowHeight = context.getWeeklyViewItemHeight()
|
||||||
for (i in 0 until ROWS_CNT) {
|
for (i in 0 until ROWS_CNT) {
|
||||||
val y = rowHeight * i.toFloat()
|
val y = rowHeight * i.toFloat()
|
||||||
canvas.drawLine(0f, y, width.toFloat(), y, paint)
|
canvas.drawLine(0f, y, width.toFloat(), y, paint)
|
||||||
|
Reference in New Issue
Block a user