Home | History | Annotate | Download | only in shadows
      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
     20   protected void __constructor__(
     21       Context context, ScaleGestureDetector.OnScaleGestureListener listener) {
     22     this.listener = listener;
     23   }
     24 
     25   @Implementation
     26   protected boolean onTouchEvent(MotionEvent event) {
     27     onTouchEventMotionEvent = event;
     28     return true;
     29   }
     30 
     31   public MotionEvent getOnTouchEventMotionEvent() {
     32     return onTouchEventMotionEvent;
     33   }
     34 
     35   public void reset() {
     36     onTouchEventMotionEvent = null;
     37     scaleFactor = 1;
     38     focusX = 0;
     39     focusY = 0;
     40   }
     41 
     42   public ScaleGestureDetector.OnScaleGestureListener getListener() {
     43     return listener;
     44   }
     45 
     46   public void setScaleFactor(float scaleFactor) {
     47     this.scaleFactor = scaleFactor;
     48   }
     49 
     50   @Implementation
     51   protected float getScaleFactor() {
     52     return scaleFactor;
     53   }
     54 
     55   public void setFocusXY(float focusX, float focusY) {
     56     this.focusX = focusX;
     57     this.focusY = focusY;
     58   }
     59 
     60   @Implementation
     61   protected float getFocusX() {
     62     return focusX;
     63   }
     64 
     65   @Implementation
     66   protected float getFocusY() {
     67     return focusY;
     68   }
     69 }
     70