diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt index 4f8232788..452e6ed1c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -93,9 +93,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { updateScrollY(Math.max(mListener?.getCurrScrollY() ?: 0, minScrollY)) } - (0..6).map { inflater.inflate(R.layout.stroke_vertical_divider, mView.week_vertical_grid_holder) } - (0..23).map { inflater.inflate(R.layout.stroke_horizontal_divider, mView.week_horizontal_grid_holder) } - wasFragmentInit = true return mView } @@ -239,7 +236,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } activity!!.runOnUiThread { - if (context != null && isAdded) { + if (context != null && activity != null && isAdded) { addEvents() } } @@ -347,9 +344,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { private fun addAllDayEvent(event: Event) { (inflater.inflate(R.layout.week_all_day_event_marker, null, false) as TextView).apply { - if (activity == null) - return - var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var textColor = backgroundColor.getContrastColor() if (dimPastEvents && event.isPastEvent) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/WeeklyViewGrid.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/WeeklyViewGrid.kt new file mode 100644 index 000000000..b133ede75 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/WeeklyViewGrid.kt @@ -0,0 +1,35 @@ +package com.simplemobiletools.calendar.views + +import android.content.Context +import android.graphics.Canvas +import android.graphics.Paint +import android.util.AttributeSet +import android.view.View +import com.simplemobiletools.calendar.R + +class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) { + private val ROWS_CNT = 24 + private val COLS_CNT = 7 + private var paint = Paint(Paint.ANTI_ALIAS_FLAG) + + constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) + + init { + paint.color = context.resources.getColor(R.color.divider_grey) + } + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + val rowHeight = height / ROWS_CNT + for (i in 0 until ROWS_CNT) { + val y = rowHeight * i.toFloat() + canvas.drawLine(0f, y, width.toFloat(), y, paint) + } + + val rowWidth = width / COLS_CNT + for (i in 0 until COLS_CNT) { + val x = rowWidth * i.toFloat() + canvas.drawLine(x, 0f, x, height.toFloat(), paint) + } + } +} diff --git a/app/src/main/res/drawable/stroke_bottom.xml b/app/src/main/res/drawable/stroke_bottom.xml index d851d1192..c229316f9 100644 --- a/app/src/main/res/drawable/stroke_bottom.xml +++ b/app/src/main/res/drawable/stroke_bottom.xml @@ -2,9 +2,9 @@ + android:left="-1px" + android:right="-1px" + android:top="-1px"> diff --git a/app/src/main/res/drawable/stroke_bottom_right.xml b/app/src/main/res/drawable/stroke_bottom_right.xml index 206722803..46574e93e 100644 --- a/app/src/main/res/drawable/stroke_bottom_right.xml +++ b/app/src/main/res/drawable/stroke_bottom_right.xml @@ -2,9 +2,9 @@ + android:top="-1px"> diff --git a/app/src/main/res/drawable/stroke_right.xml b/app/src/main/res/drawable/stroke_right.xml index 9bd8e4265..ae1dbec32 100644 --- a/app/src/main/res/drawable/stroke_right.xml +++ b/app/src/main/res/drawable/stroke_right.xml @@ -1,10 +1,10 @@ + android:top="-1px"> diff --git a/app/src/main/res/layout/fragment_week.xml b/app/src/main/res/layout/fragment_week.xml index 0ec204391..2370406d3 100644 --- a/app/src/main/res/layout/fragment_week.xml +++ b/app/src/main/res/layout/fragment_week.xml @@ -5,12 +5,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - + android:layout_height="@dimen/weekly_view_events_height"/> diff --git a/app/src/main/res/layout/stroke_horizontal_divider.xml b/app/src/main/res/layout/stroke_horizontal_divider.xml deleted file mode 100644 index 924faf4a3..000000000 --- a/app/src/main/res/layout/stroke_horizontal_divider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/app/src/main/res/layout/stroke_vertical_divider.xml b/app/src/main/res/layout/stroke_vertical_divider.xml deleted file mode 100644 index afca637d1..000000000 --- a/app/src/main/res/layout/stroke_vertical_divider.xml +++ /dev/null @@ -1,7 +0,0 @@ - -