ScaleGestureDetector needs to query the displaymetrics

for the width/height on each touch down as orientation
can change.

This should fix the problem where we can't pinch on the
top right corner when device is in landscape mode.
This commit is contained in:
Grace Kloba
2010-01-20 23:06:43 -08:00
parent e834722f54
commit d5ada83c71

View File

@ -147,12 +147,9 @@ public class ScaleGestureDetector {
public ScaleGestureDetector(Context context, OnScaleGestureListener listener) {
ViewConfiguration config = ViewConfiguration.get(context);
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
mContext = context;
mListener = listener;
mEdgeSlop = config.getScaledEdgeSlop();
mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
}
public boolean onTouchEvent(MotionEvent event) {
@ -165,6 +162,11 @@ public class ScaleGestureDetector {
event.getPointerCount() >= 2) {
// We have a new multi-finger gesture
// as orientation can change, query the metrics in touch down
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
// Be paranoid in case we missed an event
reset();