SleepTimePicker icon indicating copy to clipboard operation
SleepTimePicker copied to clipboard

Problems with ScrollView

Open pesjak opened this issue 6 years ago • 1 comments

Can't move the sliders if it is in Scroll layout.

pesjak avatar Jun 23 '19 16:06 pesjak

I managed to fixed it. I dowloaded the library and changed onTouchEvent. SOLUTION: parent.requestDisallowInterceptTouchEvent(true)

This is the full onTouchEvent code.

 @SuppressLint("ClickableViewAccessibility")
    override fun onTouchEvent(ev: MotionEvent): Boolean {
        //To make it touchable when inside of a scrollview
        parent.requestDisallowInterceptTouchEvent(true)

        val x = ev.x
        val y = ev.y

        when (ev.action) {
            MotionEvent.ACTION_DOWN -> {
                return true
            }
            MotionEvent.ACTION_MOVE -> {
                val touchAngleRad = atan2(center.y - y, x - center.x).toDouble()
                if (draggingSleep) {
                    val sleepAngleRad = Math.toRadians(sleepAngle)
                    val diff = Math.toDegrees(angleBetweenVectors(sleepAngleRad, touchAngleRad))
                    sleepAngle = to_0_720(sleepAngle + diff)
                    requestLayout()
                    notifyChanges()
                    return true
                } else if (draggingWake) {
                    val wakeAngleRad = Math.toRadians(wakeAngle)
                    val diff = Math.toDegrees(angleBetweenVectors(wakeAngleRad, touchAngleRad))
                    wakeAngle = to_0_720(wakeAngle + diff)
                    requestLayout()
                    notifyChanges()
                    return true
                }
            }
            MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
                draggingSleep = false
                draggingWake = false
            }
        }
        return super.onTouchEvent(ev)
    }

pesjak avatar Jun 23 '19 17:06 pesjak