mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
adding a helper function to remove some duplication
This commit is contained in:
@@ -253,21 +253,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
updateViewScale()
|
updateViewScale()
|
||||||
listener?.updateRowHeight(rowHeight.toInt())
|
listener?.updateRowHeight(rowHeight.toInt())
|
||||||
|
|
||||||
val fullContentHeight = rowHeight * 24
|
val targetY = rowHeightsAtScale * rowHeight - scaleCenterPercent * getVisibleHeight()
|
||||||
val visibleRatio = scrollView.height / fullContentHeight
|
|
||||||
val visibleHeight = fullContentHeight * visibleRatio
|
|
||||||
val targetY = rowHeightsAtScale * rowHeight - scaleCenterPercent * visibleHeight
|
|
||||||
scrollView.scrollTo(0, targetY.toInt())
|
scrollView.scrollTo(0, targetY.toInt())
|
||||||
return super.onScale(detector)
|
return super.onScale(detector)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScaleBegin(detector: ScaleGestureDetector): Boolean {
|
override fun onScaleBegin(detector: ScaleGestureDetector): Boolean {
|
||||||
val fullContentHeight = rowHeight * 24
|
|
||||||
val visibleRatio = scrollView.height / fullContentHeight
|
|
||||||
val visibleHeight = fullContentHeight * visibleRatio
|
|
||||||
|
|
||||||
scaleCenterPercent = detector.focusY / scrollView.height
|
scaleCenterPercent = detector.focusY / scrollView.height
|
||||||
rowHeightsAtScale = (scrollView.scrollY + scaleCenterPercent * visibleHeight) / rowHeight
|
rowHeightsAtScale = (scrollView.scrollY + scaleCenterPercent * getVisibleHeight()) / rowHeight
|
||||||
scrollView.isScrollable = false
|
scrollView.isScrollable = false
|
||||||
prevScaleSpanY = detector.currentSpanY
|
prevScaleSpanY = detector.currentSpanY
|
||||||
wasScaled = true
|
wasScaled = true
|
||||||
@@ -277,6 +270,12 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getVisibleHeight(): Float {
|
||||||
|
val fullContentHeight = rowHeight * 24
|
||||||
|
val visibleRatio = scrollView.height / fullContentHeight
|
||||||
|
return fullContentHeight * visibleRatio
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateWeeklyCalendar(events: ArrayList<Event>) {
|
override fun updateWeeklyCalendar(events: ArrayList<Event>) {
|
||||||
val newHash = events.hashCode()
|
val newHash = events.hashCode()
|
||||||
if (newHash == lastHash || mWasDestroyed || context == null) {
|
if (newHash == lastHash || mWasDestroyed || context == null) {
|
||||||
|
Reference in New Issue
Block a user