fix some glitches at swiping and zooming between fragments

This commit is contained in:
tibbi 2020-03-24 13:08:02 +01:00
parent 076f754915
commit d283d49082
3 changed files with 14 additions and 1 deletions

View File

@ -134,6 +134,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
if (isFragmentVisible && wasFragmentInit) {
listener?.updateHoursTopMargin(mView.week_top_holder.height)
checkScrollLimits(scrollView.scrollY)
// fix some glitches like at swiping from a fully zoomed out fragment will all-day events to an empty one
val fullFragmentHeight = (listener?.getFullFragmentHeight() ?: 0) - mView.week_top_holder.height
if (scrollView.height < fullFragmentHeight) {
config.weeklyViewItemHeightMultiplier = fullFragmentHeight / 24 / context!!.resources.getDimension(R.dimen.weekly_view_row_height)
updateViewScale()
listener?.updateRowHeight(rowHeight.toInt())
}
}
}
@ -263,10 +271,11 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun updateViewScale() {
rowHeight = context!!.getWeeklyViewItemHeight()
rowHeight = context?.getWeeklyViewItemHeight() ?: return
val oneDp = context!!.resources.getDimension(R.dimen.one_dp).toInt()
val fullHeight = Math.max(rowHeight.toInt() * 24, scrollView.height + oneDp)
scrollView.layoutParams.height = fullHeight - oneDp
mView.week_horizontal_grid_holder.layoutParams.height = fullHeight
mView.week_events_columns_holder.layoutParams.height = fullHeight
addEvents(currEvents)

View File

@ -222,4 +222,6 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, rowHeight)
(viewPager!!.adapter as? MyWeekPagerAdapter)?.updateNotVisibleZoomLevel(viewPager!!.currentItem)
}
override fun getFullFragmentHeight() = weekHolder!!.week_view_holder.height
}

View File

@ -8,4 +8,6 @@ interface WeekFragmentListener {
fun getCurrScrollY(): Int
fun updateRowHeight(rowHeight: Int)
fun getFullFragmentHeight(): Int
}