Merge pull request #1448 from KryptKode/fix/weekly-view-missing-days
fix week view missing some days on slider change
This commit is contained in:
commit
78e4612317
1 changed files with 31 additions and 26 deletions
|
@ -68,11 +68,40 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
}
|
||||
|
||||
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 weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
|
||||
addHours()
|
||||
|
||||
defaultWeeklyPage = weekTSs.size / 2
|
||||
|
||||
viewPager!!.apply {
|
||||
adapter = weeklyAdapter
|
||||
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
|
@ -100,31 +129,6 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
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 {
|
||||
if (weekHolder!!.week_view_seekbar.isVisible()) {
|
||||
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) {
|
||||
|
@ -215,6 +219,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
private fun updateWeeklyViewDays(days: Int) {
|
||||
context!!.config.weeklyViewDays = days
|
||||
updateDaysCount(days)
|
||||
setupWeeklyViewPager()
|
||||
}
|
||||
|
||||
private fun updateDaysCount(cnt: Int) {
|
||||
|
|
Loading…
Reference in a new issue