3131import android .graphics .Rect ;
3232import android .graphics .RectF ;
3333import android .util .AttributeSet ;
34+ import android .util .Log ;
3435import android .view .MotionEvent ;
3536import android .view .View ;
3637import android .widget .LinearLayout ;
@@ -57,6 +58,7 @@ static final private class GraphViewConfig {
5758 private class GraphViewContentView extends View {
5859 private float lastTouchEventX ;
5960 private float graphwidth ;
61+ private boolean scrollingStarted ;
6062
6163 /**
6264 * @param context
@@ -195,23 +197,32 @@ public boolean onTouchEvent(MotionEvent event) {
195197 handled = scaleDetector .isInProgress ();
196198 }
197199 if (!handled ) {
200+ Log .d ("GraphView" , "on touch event scale not handled+" +lastTouchEventX );
198201 // if not scaled, scroll
199202 if ((event .getAction () & MotionEvent .ACTION_DOWN ) == MotionEvent .ACTION_DOWN ) {
203+ scrollingStarted = true ;
200204 handled = true ;
201205 }
202206 if ((event .getAction () & MotionEvent .ACTION_UP ) == MotionEvent .ACTION_UP ) {
207+ scrollingStarted = false ;
203208 lastTouchEventX = 0 ;
204209 handled = true ;
205210 }
206211 if ((event .getAction () & MotionEvent .ACTION_MOVE ) == MotionEvent .ACTION_MOVE ) {
207- if (lastTouchEventX != 0 ) {
208- onMoveGesture (event .getX () - lastTouchEventX );
212+ if (scrollingStarted ) {
213+ if (lastTouchEventX != 0 ) {
214+ onMoveGesture (event .getX () - lastTouchEventX );
215+ }
216+ lastTouchEventX = event .getX ();
217+ handled = true ;
209218 }
210- lastTouchEventX = event .getX ();
211- handled = true ;
212219 }
213220 if (handled )
214221 invalidate ();
222+ } else {
223+ // currently scaling
224+ scrollingStarted = false ;
225+ lastTouchEventX = 0 ;
215226 }
216227 return handled ;
217228 }
0 commit comments