Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Touch events not being intercepted when in DrawerLayout #38

Closed
nemphys opened this issue Mar 6, 2014 · 7 comments
Closed

Touch events not being intercepted when in DrawerLayout #38

nemphys opened this issue Mar 6, 2014 · 7 comments
Labels

Comments

@nemphys
Copy link

nemphys commented Mar 6, 2014

Hi, I am trying to use this library inside my right drawer in Android Support DrawerLayout, but the drawer seems to be capturing the touch events, so swiping does not work.

Ideally, I would like the drawer to handle the left-to-write swipe (so that it can close by swiping; it's the right drawer) and the ExtendedListView to handle the right-to-left swipe, so that I can have swipe to delete working.

After fiddling around, I can only either get the ListView or the drawer to handle both swipes.

Any help would be appreciated...

@draskosaric
Copy link

@timroes
Copy link
Owner

timroes commented Mar 6, 2014

I have someone else having that problem, so I would like to test it and see if there is a workaround. Problem is, I know I won't have much time for it during the next weeks, since there is still laying several other work around here.

Also think, if you really want to have a swiping layout in your navigation drawer. In most cases (not necessarily all) this will create bad usability, since you are nesting containers which scroll in the same direction into each other. As you said, you only want to handle the outer container the right to left and the inner container the left to right swipe, but the question is: do your users instantly know that. If they don't see your UI and know how to interact with it, you hide functionality and created a bad usability for them. Though I don't deny there are rare cases where it makes sense.

PS: This is not a lame excuse, so I don't need to fix that, I swear I will look into it, when I find time, but somehow this spring is filled with conferences and such.

@timroes timroes added the bug label Mar 6, 2014
@nemphys
Copy link
Author

nemphys commented Mar 6, 2014

Yes, but I think this has nothing to do with my issue; it's supposed to solve the problem when children views are catching the events, not parent views (ie. drawer layout in my case).

I am thinking that if there was a getParent().requestDisallowInterceptTouchEvent(true) somewhere in the onTouchEvent code (eg. after we make sure the ListView should handle the event), it might work.

PS. I just got your reply through ajax while writing this and I see what you mean about usability; I have already implemented list item removal through a popupmenu, the swipe functionality will be a bonus eye-candy :-)

@nemphys
Copy link
Author

nemphys commented Mar 7, 2014

OK, I did some digging, and (at least for my case) the solution is a one-liner:
adding a

getParent().requestDisallowInterceptTouchEvent(true);

right after

if(isSwipeDirectionValid(deltaX)) {

in onTouchEvent method gives the desired result; and I think it actually makes sense, since it means "I will handle the event, parents should leave it alone".

If you would be so kind to take a look at it (and hopefully merge it), I would be really grateful (and it would save me the trouble of importing the project source as a library, etc).

@timroes
Copy link
Owner

timroes commented Mar 7, 2014

Sounds like a good solution and seem to work right now. I hope this won't break some cases where the parent needs to intercept the children even in that cases (that I might not have thought about). Will be pushing it soon.

@timroes timroes closed this as completed in 7d9df39 Mar 7, 2014
@timroes
Copy link
Owner

timroes commented Mar 7, 2014

Released with v0.3.2. Should be synced in maven central in some hours.
If anyone find cases in which this interception handling causes problems now in the new release, please tell me.

@C0nstan
Copy link

C0nstan commented Aug 18, 2014

it is a problem if used with PullToRefresh: https://github.com/chrisbanes/ActionBar-PullToRefresh
it steals the Touch and the pull to refresh isn't working anymore.
Maybe it is possible to requestDisallowInterceptTouchEvent only if the touch is currently moving in horizontal direction

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants