diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyWeekPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyWeekPagerAdapter.kt index 1f5379cba..05cd91d73 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyWeekPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyWeekPagerAdapter.kt @@ -42,4 +42,10 @@ class MyWeekPagerAdapter(fm: FragmentManager, private val mWeekTimestamps: List< mFragments[pos - 1]?.updateNotVisibleViewScaleLevel() mFragments[pos + 1]?.updateNotVisibleViewScaleLevel() } + + fun updateVisibleDaysCount(pos: Int, count: Int) { + for (i in -1..1) { + mFragments[pos + i]?.updateVisibleDaysCount(count) + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index 1c1280f56..c70089820 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -169,6 +169,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + fun updateVisibleDaysCount(count: Int) { + mView.week_horizontal_grid_holder.apply { + daysCount = count + invalidate() + } + } + private fun setupDayLabels() { var curDay = Formatter.getDateTimeFromTS(weekTimestamp) val textColor = config.textColor diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index 11b2e8114..77187fc21 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -207,6 +207,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { private fun updateDaysCount(cnt: Int) { weekHolder!!.week_view_days_count.text = context!!.resources.getQuantityString(R.plurals.days, cnt, cnt) + (viewPager?.adapter as? MyWeekPagerAdapter)?.updateVisibleDaysCount(viewPager!!.currentItem, cnt) } override fun refreshEvents() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt index f4d1ee6a1..b07cf623d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt @@ -10,8 +10,8 @@ import com.simplemobiletools.calendar.pro.extensions.getWeeklyViewItemHeight 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) + var daysCount = 7 constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) @@ -27,8 +27,8 @@ class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie canvas.drawLine(0f, y, width.toFloat(), y, paint) } - val rowWidth = width / COLS_CNT.toFloat() - for (i in 0 until COLS_CNT) { + val rowWidth = width / daysCount.toFloat() + for (i in 0 until daysCount) { val x = rowWidth * i.toFloat() canvas.drawLine(x, 0f, x, height.toFloat(), paint) }