couple weekly view scrolling related fixes

This commit is contained in:
tibbi 2017-02-04 14:44:56 +01:00
parent 90168af9f4
commit 1290883716
3 changed files with 6 additions and 4 deletions

View File

@ -261,6 +261,7 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
weeklyAdapter.updateScrollY(week_view_view_pager.currentItem, y)
}
})
week_view_hours_scrollview.setOnTouchListener({ view, motionEvent -> true })
}
fun updateHoursTopMargin(margin: Int) {

View File

@ -27,7 +27,7 @@ class MyWeekPagerAdapter(fm: FragmentManager, val mWeekTimestamps: List<Int>, va
}
fun updateScrollY(pos: Int, y: Int) {
(-1..1).map { mFragments[pos + it] }
.forEach { it?.updateScrollY(y) }
mFragments[pos - 1].updateScrollY(y)
mFragments[pos + 1].updateScrollY(y)
}
}

View File

@ -60,8 +60,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
week_events_scrollview.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
updateScrollY(Math.max(MainActivity.mWeekScrollY, minScrollY))
week_events_scrollview.viewTreeObserver.removeOnGlobalLayoutListener(this)
updateScrollY(Math.max(MainActivity.mWeekScrollY, minScrollY))
}
})
@ -145,7 +145,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} else if (maxScrollY != -1 && y > maxScrollY) {
mView.week_events_scrollview.scrollY = maxScrollY
} else {
mListener?.scrollTo(y)
if (isFragmentVisible)
mListener?.scrollTo(y)
}
}