mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add some threshold at the weekly view zoom, ignore too small changes
This commit is contained in:
@ -64,7 +64,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.23.9'
|
implementation 'com.simplemobiletools:commons:5.23.10'
|
||||||
implementation 'joda-time:joda-time:2.10.1'
|
implementation 'joda-time:joda-time:2.10.1'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||||
|
@ -35,6 +35,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
private val PLUS_FADEOUT_DELAY = 5000L
|
private val PLUS_FADEOUT_DELAY = 5000L
|
||||||
private val MIN_SCALE_FACTOR = 0.3f
|
private val MIN_SCALE_FACTOR = 0.3f
|
||||||
private val MAX_SCALE_FACTOR = 5f
|
private val MAX_SCALE_FACTOR = 5f
|
||||||
|
private val MIN_SCALE_DIFFERENCE = 0.02f
|
||||||
private val SCALE_RANGE = MAX_SCALE_FACTOR - MIN_SCALE_FACTOR
|
private val SCALE_RANGE = MAX_SCALE_FACTOR - MIN_SCALE_FACTOR
|
||||||
|
|
||||||
var listener: WeekFragmentListener? = null
|
var listener: WeekFragmentListener? = null
|
||||||
@ -48,6 +49,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
private var defaultRowHeight = 0f
|
private var defaultRowHeight = 0f
|
||||||
private var screenHeight = 0
|
private var screenHeight = 0
|
||||||
private var rowHeightsAtScale = 0f
|
private var rowHeightsAtScale = 0f
|
||||||
|
private var prevScaleFactor = 0f
|
||||||
private var mWasDestroyed = false
|
private var mWasDestroyed = false
|
||||||
private var isFragmentVisible = false
|
private var isFragmentVisible = false
|
||||||
private var wasFragmentInit = false
|
private var wasFragmentInit = false
|
||||||
@ -249,12 +251,15 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
newFactor = scrollView.height / 24f / defaultRowHeight
|
newFactor = scrollView.height / 24f / defaultRowHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Math.abs(newFactor - prevScaleFactor) > MIN_SCALE_DIFFERENCE) {
|
||||||
|
prevScaleFactor = newFactor
|
||||||
config.weeklyViewItemHeightMultiplier = newFactor
|
config.weeklyViewItemHeightMultiplier = newFactor
|
||||||
updateViewScale()
|
updateViewScale()
|
||||||
listener?.updateRowHeight(rowHeight.toInt())
|
listener?.updateRowHeight(rowHeight.toInt())
|
||||||
|
|
||||||
val targetY = rowHeightsAtScale * rowHeight - scaleCenterPercent * getVisibleHeight()
|
val targetY = rowHeightsAtScale * rowHeight - scaleCenterPercent * getVisibleHeight()
|
||||||
scrollView.scrollTo(0, targetY.toInt())
|
scrollView.scrollTo(0, targetY.toInt())
|
||||||
|
}
|
||||||
return super.onScale(detector)
|
return super.onScale(detector)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +268,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
rowHeightsAtScale = (scrollView.scrollY + scaleCenterPercent * getVisibleHeight()) / rowHeight
|
rowHeightsAtScale = (scrollView.scrollY + scaleCenterPercent * getVisibleHeight()) / rowHeight
|
||||||
scrollView.isScrollable = false
|
scrollView.isScrollable = false
|
||||||
prevScaleSpanY = detector.currentSpanY
|
prevScaleSpanY = detector.currentSpanY
|
||||||
|
prevScaleFactor = config.weeklyViewItemHeightMultiplier
|
||||||
wasScaled = true
|
wasScaled = true
|
||||||
screenHeight = context!!.realScreenSize.y
|
screenHeight = context!!.realScreenSize.y
|
||||||
return super.onScaleBegin(detector)
|
return super.onScaleBegin(detector)
|
||||||
|
Reference in New Issue
Block a user