I'm trying to intercept onTouchEvent and use the movement to set the number
of seconds on a simple timer. The idea is that if you touch your finger on
the screen and move left or right, up or down the counter will move higher
or lower.  My code works but for some reason the increments are not smooth.
Down movements are short and jerky compared to up movements for example. I'm
having a hard time finding any reason for this. My code follows:

   @Override
   public boolean onTouchEvent(MotionEvent event) {
    Message m = new Message();
    m.what = timer.GUIUPDATEIDENTIFIER;
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
       startX = (int)event.getX();
       startY = (int)event.getY();
       return true;
    case MotionEvent.ACTION_MOVE:
       endX = (int)event.getX();
       endY = (int)event.getY();
       if((endY - startY) < 0) {
       this.mySecondsTotal += 1;
       } else {
       this.mySecondsTotal -= 1;
       }
       if((endX - startX) < 0) {
       this.mySecondsTotal -= 1;
       } else {
       this.mySecondsTotal += 1;
       }
       startX = (int)event.getX();
       startY = (int)event.getY();
       if (this.mySecondsTotal < 0)
          this.mySecondsTotal = 0;
       DEFAULTSECONDS = this.mySecondsTotal;
       this.myYogaViewUpdateHandler.sendMessage(m);
       return true;
    case MotionEvent.ACTION_UP:
       endX = (int)event.getX();
       endY = (int)event.getY();
       return true;
    }
    return false;
   }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to