-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable scroll but allow tap on item #38
Comments
@kizitonwose I tried the same on my end by adding:
to the example you mentioned but I got the same result... I can't tap on a day... |
That's very strange. Can you test with a different phone? Sadly, this is a problem with |
@kizitonwose unfortunately it also happens on Samsung devices but it's strange because it does works on other like Xiaomi. :/ |
Currently waiting to get a Samsung device to test with. |
I finally got my hands on a Samsung device and can confirm that the suggested workaround does not work on the device. However, after further testing, there's another workaround which works on Samsung devices as well as other devices which I tested on: calendarView.addOnItemTouchListener(object : RecyclerView.SimpleOnItemTouchListener() {
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean {
return rv.scrollState == RecyclerView.SCROLL_STATE_DRAGGING
}
}) For reference purposes, here are other things I tried and how they turned out. calendarView.setOnTouchListener { _, event ->
event.action == MotionEvent.ACTION_MOVE
} The above workaround allows an initial scroll action on the calendar before taking effect which is rather weird. Another option is to extend the override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
return if (ev.action == MotionEvent.ACTION_MOVE) true else super.dispatchTouchEvent(ev)
} This gives the desired result. However, while the calendar does not move after a swipe action, a touch event is registered at the start position of the swipe gesture, hence the date cell at that position receives a click event. |
Closing this issue as there's now a solution. If you need any further assistance, let me know. |
@kizitonwose I'm stuck with the following situacion...
On one hand I need to disable the horizontal scrolling on the calendar as shown on here: #13 and do it programatically.
But at the same time I need to be able to tap/click on days of the calendar (by setting a click listener on the DayViewContainer view):
view.setOnClickListener(new View.OnClickListener()...
The problem is that by disabling the scroll I'm intercepting the Action.MOVE used by the taps as well, therefore onInterceptTouchEvent is swallowing the event, hence not allowing it to reach the defined view click listener.
So to sum up I need to disable the swiping of the calendar but allowing taps of each of days of the calendar...
Any suggestion?
Thanks in advance,
Federico
The text was updated successfully, but these errors were encountered: