VolumeControlView icon indicating copy to clipboard operation
VolumeControlView copied to clipboard

Ability to set the current angle or progress instead of just start

Open AddictArts opened this issue 6 years ago • 2 comments

I was able to work around the limitation by using a synthesized MoutionEvent.

AddictArts avatar Aug 04 '17 00:08 AddictArts

@AddictArts Sorry, what do you mean?

ukevgen avatar Aug 14 '17 07:08 ukevgen

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)
}

AddictArts avatar Aug 14 '17 22:08 AddictArts