VolumeControlView
VolumeControlView copied to clipboard
Ability to set the current angle or progress instead of just start
I was able to work around the limitation by using a synthesized MoutionEvent.
@AddictArts Sorry, what do you mean?
For example a seek bar has setProgress
. Currently you can indicate a start, but not externally set it programatically. I worked around this by using a synthetic onTouch event like so:
private fun setVolumeControlViewProgress(v: VolumeControlView, progress: Int) {
val w: Int = v.width
val h: Int = v.height
val controllerCenter = PointF().apply {
x = w / 2f
y = h / 2f
}
val controllerRadius = if (w > h) h / CONTROLLER_SPACE else w / CONTROLLER_SPACE
val restoreTouchPoint = getPointOnBorderLineOfCircle(controllerCenter, controllerRadius, (progress * 360) / 100)
val motionEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, restoreTouchPoint.x, restoreTouchPoint.y, 0)
v.onTouch(contentView!!, motionEvent)
}