android – How to implement Double Tap and Touch Event on a view at the same time?-ThrowExceptions

Exception or error:

In my app I am basically setting touch listener to a TextView however the use case is really complex in the touch I’m trying to detect double tap using gesture detector and for that to work I need to return true but however on touch the event is also need to sent to other view for that I’m doing view.onTouchEvent(event); this requires you to return false hence there are conflicts in my touch listener which eventually results in either of two not working what I want to do is that both use cases should work.

Here’s what I’m doing:

   tv_main!!.setOnTouchListener(object : OnTouchListener{
           override fun onTouch(v: View?, event: MotionEvent?): Boolean {
               if (gestureDetector.onTouchEvent(event)) {
                       EventBus.getDefault().post("ShowTextSheet")
                       return true
                   } else {
                       setevent(event)
                       return false
                   }
           }
       })
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *