use of com.marshalchen.common.uimodule.gesturedetectors.MoveGestureDetector in project UltimateAndroid by cymcsg.
the class GestureTouchActivity method onCreate.
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gesture_activity);
// Determine the center of the screen to center 'gesture_earth'
Display display = getWindowManager().getDefaultDisplay();
mFocusX = display.getWidth() / 2f;
mFocusY = display.getHeight() / 2f;
// Set this class as touchListener to the ImageView
ImageView view = (ImageView) findViewById(R.id.imageView);
view.setOnTouchListener(this);
// Determine dimensions of 'gesture_earth' image
Drawable d = this.getResources().getDrawable(R.drawable.gesture_earth);
mImageHeight = d.getIntrinsicHeight();
mImageWidth = d.getIntrinsicWidth();
// View is scaled and translated by matrix, so scale and translate initially
float scaledImageCenterX = (mImageWidth * mScaleFactor) / 2;
float scaledImageCenterY = (mImageHeight * mScaleFactor) / 2;
mMatrix.postScale(mScaleFactor, mScaleFactor);
mMatrix.postTranslate(mFocusX - scaledImageCenterX, mFocusY - scaledImageCenterY);
view.setImageMatrix(mMatrix);
// Setup Gesture Detectors
mScaleDetector = new ScaleGestureDetector(getApplicationContext(), new ScaleListener());
mRotateDetector = new RotateGestureDetector(getApplicationContext(), new RotateListener());
mMoveDetector = new MoveGestureDetector(getApplicationContext(), new MoveListener());
mShoveDetector = new ShoveGestureDetector(getApplicationContext(), new ShoveListener());
}
Aggregations