android: how to detect horizontal and vertical gesture lines -


i have objects want connect lines. user should able simple line-gesture. use gestureoverlayview , read article http://developer.android.com/resources/articles/gestures.html, says following

orientation: indicates scroll orientation of views underneath. in case list scrolls vertically, means horizontal gestures (like action_delete) can recognized gesture. gestures start vertical stroke must contain @ least 1 horizontal component recognized. in other words, simple vertical line cannot recognized gesture since conflict list's scrolling.

and problem - want draw lines horizontal , vertical

now have ongestureperfomedlistener, normal gesture recognition , additionally gestureoverlayview.ongesturelistener, in detect lines. want draw dashed line - vertical , horizontal. easier, if complete gesture in ongestureperformedlistener, instead of every single stroke of dashed line, in ongesturelistener.

any ideas how can solve ? there method, called when gesturing done, if not recognised ? tried use gesturedetector.ongesturelistener, use detect longpress, won't problem.

found similar solution in other threads might useful (and else may come across issue). need serious tinkering adapted purposes think close:

//swipe direction detection constants private static final int swipe_min_distance = 120; private static final int swipe_max_off_path = 250; private static final int swipe_threshold_velocity = 200;  @override protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.activity_main);      //gesture detection     this.gesturedetector = new gesturedetectorcompat(this,this);     gesturedetector.setondoubletaplistener(this); }  //on gesture... @override public boolean onsingletapconfirmed(motionevent e) {     return true; }  @override public boolean ondoubletap(motionevent e) {     return true; }  @override public boolean ondoubletapevent(motionevent e) {     return true; }  @override public boolean ondown(motionevent e) {     return true; }  @override public void onshowpress(motionevent e) {  }  @override public boolean onsingletapup(motionevent e) {     return true; }  @override public boolean onscroll(motionevent e1, motionevent e2, float distancex, float distancey) {     return true; }  @override public void onlongpress(motionevent e) {  }  @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) {      try {         // right left swipe         if (e1.getx() - e2.getx() > swipe_min_distance                 && math.abs(velocityx) > swipe_threshold_velocity) {             //do something...         }         // left right swipe         else if (e2.getx() - e1.getx() > swipe_min_distance                 && math.abs(velocityx) > swipe_threshold_velocity) {             //do something...         }         // top bottom swipe         if (e1.gety() - e2.gety() > swipe_min_distance                 && math.abs(velocityy) > swipe_threshold_velocity) {             //do something...         }         // bottom top swipe         else if (e2.gety() - e1.gety() > swipe_min_distance                 && math.abs(velocityy) > swipe_threshold_velocity) {             //do something...         }     } catch (exception e) {         return false;     }      return true;  }  @override public boolean ontouchevent(motionevent event) {     this.gesturedetector.ontouchevent(event);     return super.ontouchevent(event); } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -