Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onScroll
override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float)
: Boolean {
val rotationDegrees = calculateAngle(e2.x, e2.y)
// use only -150 to 150 range (knob min/max points
if (rotationDegrees >= -150 && rotationDegrees <= 150) {
setKnobPosition(rotationDegrees)
// Calculate rotary value
// The range is the 300 degrees between -150 and 150, so we'll add 150 to adjust the
// range to 0 - 300
val valueRangeDegrees = rotationDegrees + 150
value = ((valueRangeDegrees / divider) + minValue).toInt()
if (listener != null) listener!!.onRotate(value)
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.