understanding android handling of touch events
TRANSCRIPT
Quick CV
• TU Berlin Computer Science Diploma 1986 • Freelance Consultant since 1993 (Hospitality,
Banking)• Android Programming since 4/2014
My Task
Implement a restaurant check split screen to easily select order items.Use ExpandableListView to represent restaurant check. ExpandableListView_1
My Task
Implement a Swipe Gesture such asSwipe from left to right select one orderSwipe from right to left unselect one order
Android Touch Events
• ACTION_DOWN• ACTION_UP• ACTION_MOVE• ACTION_POINTER_DOWN• ACTION_POINTER_UP• ACTION_CANCELGesture always starts with ACTION_DOWN
Implementation Swipe
Implement a View.OnTouchListenerOther alternative is subclassing fromExpandableListView and override onTouch() ExpandableListView_2
Error Analysis
After applying TouchListener, collapse/expandand scroll don‘t work any more.
Event Path ACTION_DOWN
ActivitydispatchTouch
Event()
ExpandableListView
dispatchTouchEvent()
ViewGroupdispatchTouch
Event()
ViewdispatchTouch
Event()
ActivityonTouch()
ExpandableListView
onTouch()
ViewGrouponTouch()
ViewonTouch()
Event Path ACTION_UP
ActivitydispatchTouch
Event()
ExpandableListView
dispatchTouchEvent()
ViewGroupdispatchTouch
Event()
ViewGrouponTouch()
Final Solution
Events need to be handled on ExpandableListView and not on the item ViewGroup level to harmonize between scrolland swipe ExpandableListView_3
End of Presentation
Thank you for your attentionPresentation can be found on http://
www.slideshare.net/jensmohr/understanding-android-handling-of-touch-events
Source Code on Githubhttps://
github.com/pontisoft/ExpandableListView_1 2 and 3