mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-20 21:01:45 +01:00
fix week view missing some days on slider change
- reset the view pager to recalculate the week time stamps to get accurate number of days
This commit is contained in:
parent
56d010d94a
commit
a2bac74306
@ -60,11 +60,40 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFragment() {
|
private fun setupFragment() {
|
||||||
|
addHours()
|
||||||
|
setupWeeklyViewPager()
|
||||||
|
|
||||||
|
weekHolder!!.week_view_hours_scrollview.setOnTouchListener { view, motionEvent -> true }
|
||||||
|
|
||||||
|
weekHolder!!.week_view_seekbar.apply {
|
||||||
|
progress = context?.config?.weeklyViewDays ?: 7
|
||||||
|
max = MAX_SEEKBAR_VALUE
|
||||||
|
|
||||||
|
onSeekBarChangeListener {
|
||||||
|
if (it == 0) {
|
||||||
|
progress = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
updateWeeklyViewDays(progress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// avoid seekbar width changing if the days count changes to 1, 10 etc
|
||||||
|
weekHolder!!.week_view_days_count.onGlobalLayout {
|
||||||
|
weekHolder!!.week_view_seekbar.layoutParams.width = weekHolder!!.week_view_seekbar.width
|
||||||
|
(weekHolder!!.week_view_seekbar.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.START_OF)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDaysCount(context?.config?.weeklyViewDays ?: 7)
|
||||||
|
updateActionBarTitle()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupWeeklyViewPager(){
|
||||||
val weekTSs = getWeekTimestamps(currentWeekTS)
|
val weekTSs = getWeekTimestamps(currentWeekTS)
|
||||||
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
|
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
|
||||||
addHours()
|
|
||||||
|
|
||||||
defaultWeeklyPage = weekTSs.size / 2
|
defaultWeeklyPage = weekTSs.size / 2
|
||||||
|
|
||||||
viewPager!!.apply {
|
viewPager!!.apply {
|
||||||
adapter = weeklyAdapter
|
adapter = weeklyAdapter
|
||||||
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
@ -92,29 +121,6 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||||||
weeklyAdapter.updateScrollY(viewPager!!.currentItem, y)
|
weeklyAdapter.updateScrollY(viewPager!!.currentItem, y)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
weekHolder!!.week_view_hours_scrollview.setOnTouchListener { view, motionEvent -> true }
|
|
||||||
|
|
||||||
weekHolder!!.week_view_seekbar.apply {
|
|
||||||
progress = context?.config?.weeklyViewDays ?: 7
|
|
||||||
max = MAX_SEEKBAR_VALUE
|
|
||||||
|
|
||||||
onSeekBarChangeListener {
|
|
||||||
if (it == 0) {
|
|
||||||
progress = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
updateWeeklyViewDays(progress)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// avoid seekbar width changing if the days count changes to 1, 10 etc
|
|
||||||
weekHolder!!.week_view_days_count.onGlobalLayout {
|
|
||||||
weekHolder!!.week_view_seekbar.layoutParams.width = weekHolder!!.week_view_seekbar.width
|
|
||||||
(weekHolder!!.week_view_seekbar.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.START_OF)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateDaysCount(context?.config?.weeklyViewDays ?: 7)
|
|
||||||
updateActionBarTitle()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addHours(textColor: Int = context!!.config.textColor) {
|
private fun addHours(textColor: Int = context!!.config.textColor) {
|
||||||
@ -205,6 +211,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||||||
private fun updateWeeklyViewDays(days: Int) {
|
private fun updateWeeklyViewDays(days: Int) {
|
||||||
context!!.config.weeklyViewDays = days
|
context!!.config.weeklyViewDays = days
|
||||||
updateDaysCount(days)
|
updateDaysCount(days)
|
||||||
|
setupWeeklyViewPager()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDaysCount(cnt: Int) {
|
private fun updateDaysCount(cnt: Int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user