mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-31 10:54:51 +01:00
make the grid columnt count dynamic at weekly view
This commit is contained in:
parent
783890bf46
commit
507719af7c
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user