Search in sources :

Example 1 with ShoveGestureDetector

use of com.marshalchen.common.uimodule.gesturedetectors.ShoveGestureDetector 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());
}
Also used : MoveGestureDetector(com.marshalchen.common.uimodule.gesturedetectors.MoveGestureDetector) Drawable(android.graphics.drawable.Drawable) ShoveGestureDetector(com.marshalchen.common.uimodule.gesturedetectors.ShoveGestureDetector) ImageView(android.widget.ImageView) ScaleGestureDetector(android.view.ScaleGestureDetector) RotateGestureDetector(com.marshalchen.common.uimodule.gesturedetectors.RotateGestureDetector) Display(android.view.Display)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 Display (android.view.Display)1 ScaleGestureDetector (android.view.ScaleGestureDetector)1 ImageView (android.widget.ImageView)1 MoveGestureDetector (com.marshalchen.common.uimodule.gesturedetectors.MoveGestureDetector)1 RotateGestureDetector (com.marshalchen.common.uimodule.gesturedetectors.RotateGestureDetector)1 ShoveGestureDetector (com.marshalchen.common.uimodule.gesturedetectors.ShoveGestureDetector)1