1 package org.robolectric.shadows; 2 3 import android.content.Context; 4 import android.view.MotionEvent; 5 import android.view.ScaleGestureDetector; 6 import org.robolectric.annotation.Implementation; 7 import org.robolectric.annotation.Implements; 8 9 @SuppressWarnings({"UnusedDeclaration"}) 10 @Implements(ScaleGestureDetector.class) 11 public class ShadowScaleGestureDetector { 12 13 private MotionEvent onTouchEventMotionEvent; 14 private ScaleGestureDetector.OnScaleGestureListener listener; 15 private float scaleFactor = 1; 16 private float focusX; 17 private float focusY; 18 19 @Implementation __constructor__( Context context, ScaleGestureDetector.OnScaleGestureListener listener)20 protected void __constructor__( 21 Context context, ScaleGestureDetector.OnScaleGestureListener listener) { 22 this.listener = listener; 23 } 24 25 @Implementation onTouchEvent(MotionEvent event)26 protected boolean onTouchEvent(MotionEvent event) { 27 onTouchEventMotionEvent = event; 28 return true; 29 } 30 getOnTouchEventMotionEvent()31 public MotionEvent getOnTouchEventMotionEvent() { 32 return onTouchEventMotionEvent; 33 } 34 reset()35 public void reset() { 36 onTouchEventMotionEvent = null; 37 scaleFactor = 1; 38 focusX = 0; 39 focusY = 0; 40 } 41 getListener()42 public ScaleGestureDetector.OnScaleGestureListener getListener() { 43 return listener; 44 } 45 setScaleFactor(float scaleFactor)46 public void setScaleFactor(float scaleFactor) { 47 this.scaleFactor = scaleFactor; 48 } 49 50 @Implementation getScaleFactor()51 protected float getScaleFactor() { 52 return scaleFactor; 53 } 54 setFocusXY(float focusX, float focusY)55 public void setFocusXY(float focusX, float focusY) { 56 this.focusX = focusX; 57 this.focusY = focusY; 58 } 59 60 @Implementation getFocusX()61 protected float getFocusX() { 62 return focusX; 63 } 64 65 @Implementation getFocusY()66 protected float getFocusY() { 67 return focusY; 68 } 69 } 70