-
Notifications
You must be signed in to change notification settings - Fork 971
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
Touch event is not emitted when handled func returns false in ViewTouchOnSubscribe #204
Comments
That seems reasonable to me, but it does mean there will be a behavior change. I think that's more correct though, since sometimes you do just want to listen (but not fully handle) touch events. |
According to this commit I believe it applies to more classes: |
I would not be happy with that change as proposed. There's no longer a way for the downstream code to know if the event was handled or not when the function is truly conditional (e.g., point inside a circle). I understand the need to observe without consuming, but I think we need to come up with a way to support the filtering case as well, without having to run the conditional function twice. |
@JakeWharton you're right that there's no longer a way for downstream code to know if the event was handled. However in current implementation value won't be propagated to the downstream code right? |
Any progress on an approach to take here? I have a case with nested ViewPagers where the inner ViewPager needs to prevent the parent from changing pages if the inner's current item is the first or last item. Following this, the inner ViewPager automatically changes it's current item after a period of time, but this needs to be cancelled on |
RatingBar won't work if subscribe to |
I have a view, I want to listen to Using stock android approach I do
and it works. Switching to RxBinding approach my code is
and it won't work since passed So far I'll have to stick with android-way, because Rx-way in just not usable for my case. |
@Den-Rimus Does your solution differ somehow from mine posted in very first comment? |
Actually, it does not, sorry. Now that I've read thread more carefully I see that the problem was fully discussed, but can't be fixed due to breaking existing API. Note that documentation on second param says exactly what we would expect, and not how it works now. |
Any update on this? I'm having a scenario where longClickEvent is being interrupted by this event. |
Why not an overloaded method specifically for this use case? (non-breaking change)
|
That overload already exists: |
If the My use case is that I want to observe touch events without consuming them.
From ViewTouchObservable |
I expected it would work like this, too
|
This is my work-around for the moment:
|
Hi. Before creating a PR I would like to ask you guys if I'm right.
ViewTouchOnSubscribe
class which is internally used during for exampleRxView.touches
method contains:Current implementation probably blocks possibility to handle emitted
MotionEvent
whenhandled
function returns false for example:In above case, no value will be emitted. When it's needed? When we want to detect touch on
EditText
widget and don't "consume" theMotionEvent
. We can't consume it if we just want to make some extra action but keepEditText
to get focus (that's why handled have to returnfalse
).My proposed solution:
Am I correct or I did something wrong?
The text was updated successfully, but these errors were encountered: