Skip to content

Commit a1efa05

Browse files
committed
fix 'pointerIndex out of range' exception
1 parent c6967b8 commit a1efa05

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎Source/ZXing.Net.Mobile.Android/ZXingSurfaceView.cs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,16 @@ public override bool OnTouchEvent (MotionEvent e)
360360
{
361361
var r = base.OnTouchEvent (e);
362362

363-
// Get the last 'touch' coordinate from the touch event
364-
// (could be multiple coordinates on a drag event)
365-
// We only care about where the finger was lifted
366-
var mostRecentPointer = e.GetPointerId (e.PointerCount - 1);
367-
368-
// Get our X / Y coordinates for the most recent pointer
369-
var touchX = e.GetX (mostRecentPointer);
370-
var touchY = e.GetY (mostRecentPointer);
371-
372-
AutoFocus ((int)touchX, (int)touchY);
363+
switch (e.Action)
364+
{
365+
case MotionEventActions.Down:
366+
return true;
367+
case MotionEventActions.Up:
368+
var touchX = e.GetX();
369+
var touchY = e.GetY();
370+
this.AutoFocus((int)touchX, (int)touchY);
371+
break;
372+
}
373373

374374
return r;
375375
}

0 commit comments

Comments
 (0)