From f08223cca2f91e55dd72527921634c1307c51598 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Mon, 7 Nov 2011 14:17:01 -0800 Subject: [PATCH] Move the ScaleGestureDetector.OnScaleGestureListener implementation over to PanZoomController rather than delegating through LayerController. --- embedding/android/gfx/LayerController.java | 21 ++++----------------- embedding/android/gfx/LayerView.java | 2 +- embedding/android/ui/PanZoomController.java | 5 ++++- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/embedding/android/gfx/LayerController.java b/embedding/android/gfx/LayerController.java index 6c80ec310cd4..af846edc5da8 100644 --- a/embedding/android/gfx/LayerController.java +++ b/embedding/android/gfx/LayerController.java @@ -58,7 +58,7 @@ import java.util.ArrayList; * zooming natively by delegating to a panning/zooming controller. Touch events can be dispatched * to a higher-level view. */ -public class LayerController implements ScaleGestureDetector.OnScaleGestureListener { +public class LayerController { private Layer mRootLayer; /* The root layer. */ private LayerView mView; /* The main rendering view. */ private Context mContext; /* The current context. */ @@ -98,8 +98,8 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe else mPageSize = new IntSize(LayerController.TILE_WIDTH, LayerController.TILE_HEIGHT); - mView = new LayerView(context, this); mPanZoomController = new PanZoomController(this); + mView = new LayerView(context, this); } public void setRoot(Layer layer) { mRootLayer = layer; } @@ -121,6 +121,8 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe public Bitmap getCheckerboardPattern() { return getDrawable("checkerboard"); } public Bitmap getShadowPattern() { return getDrawable("shadow"); } + public ScaleGestureDetector.OnScaleGestureListener getScaleGestureListener() { return mPanZoomController; } + private Bitmap getDrawable(String name) { Resources resources = mContext.getResources(); int resourceID = resources.getIdentifier(name, "drawable", mContext.getPackageName()); @@ -256,21 +258,6 @@ public class LayerController implements ScaleGestureDetector.OnScaleGestureListe return result; } - @Override - public boolean onScale(ScaleGestureDetector detector) { - return mPanZoomController.onScale(detector); - } - - @Override - public boolean onScaleBegin(ScaleGestureDetector detector) { - return mPanZoomController.onScaleBegin(detector); - } - - @Override - public void onScaleEnd(ScaleGestureDetector detector) { - mPanZoomController.onScaleEnd(detector); - } - /** * Objects that wish to listen for changes in the layer geometry (visible rect or screen size) * should implement this interface and register themselves with addOnGeometryChangeListener(). diff --git a/embedding/android/gfx/LayerView.java b/embedding/android/gfx/LayerView.java index a22afa29b165..d60614a14d1a 100644 --- a/embedding/android/gfx/LayerView.java +++ b/embedding/android/gfx/LayerView.java @@ -68,7 +68,7 @@ public class LayerView extends GLSurfaceView { mController = controller; mRenderer = new LayerRenderer(this); setRenderer(mRenderer); - mScaleGestureDetector = new ScaleGestureDetector(context, controller); + mScaleGestureDetector = new ScaleGestureDetector(context, controller.getScaleGestureListener()); mInputConnectionHandler = null; setFocusable(true); diff --git a/embedding/android/ui/PanZoomController.java b/embedding/android/ui/PanZoomController.java index e4754a42f4b5..b4ac487366ec 100644 --- a/embedding/android/ui/PanZoomController.java +++ b/embedding/android/ui/PanZoomController.java @@ -53,7 +53,7 @@ import java.util.TimerTask; * Many ideas are from Joe Hewitt's Scrollability: * https://github.com/joehewitt/scrollability/ */ -public class PanZoomController { +public class PanZoomController implements ScaleGestureDetector.OnScaleGestureListener { private LayerController mController; private static final float FRICTION = 0.97f; @@ -477,6 +477,7 @@ public class PanZoomController { /* * Zooming */ + @Override public boolean onScale(ScaleGestureDetector detector) { float newZoom = detector.getCurrentSpan() / mInitialZoomSpan; @@ -491,6 +492,7 @@ public class PanZoomController { return true; } + @Override public boolean onScaleBegin(ScaleGestureDetector detector) { IntRect initialZoomRect = (IntRect)mController.getVisibleRect().clone(); float initialZoom = mController.getZoomFactor(); @@ -501,6 +503,7 @@ public class PanZoomController { return true; } + @Override public void onScaleEnd(ScaleGestureDetector detector) { // TODO }