Android ScaleGestureDetector - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ScaleGestureDetector class.

This code example shows how to use the following methods:getFocusX, getFocusY, getScaleFactor
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getFocusX, getFocusY, getScaleFactor
        private float mLastY;
         
        private class Listener implements ScaleGestureDetector.OnScaleGestureListener {
 
            public boolean onScale(ScaleGestureDetector detector) {
                float scale = detector.getScaleFactor();
                 
                Log.d("ttest", "Scale: " + scale);
                 
                // Limit the scale so our object doesn't get too big or disappear 
                if (mScale * scale > 0.1f) {
                    if (mScale * scale < 10.f) {
                        mScale *= scale;
                    } else { 
                        mScale = 10.f;
                    } 
                } else { 
                    mScale = 0.1f;
                } 
                 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getScaleFactor
    } 
 
    private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
        @Override 
        public boolean onScale(ScaleGestureDetector detector) {
            mRender.onActionScale(detector.getScaleFactor());
            return true; 
        } 
    } 
} 
 
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isInProgress, onTouchEvent
        } 
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getScaleFactor
    } 
 
    private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
        @Override 
        public boolean onScale(ScaleGestureDetector detector) {
            mRender.onActionScale(detector.getScaleFactor());
            return true; 
        } 
    } 
 
    public void onSensorChanged(SensorEvent event) {
        // we received a sensor event. it is a good practice to check 
        // that we received the proper event 
        if (mUseSensor) {
            if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
                // convert the rotation-vector to a 4x4 matrix. the matrix 
                // is interpreted by Open GL as the inverse of the 
                // rotation-vector, which is what we want. 
                SensorManager.getRotationMatrixFromVector(
                        mRotationMatrix , event.values);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getEventTime, getFocusX, getFocusY, getScaleFactor
            // ContentView to ignore the onScaleBegin() call. And if webkit does not 
            // handle the touch move events afterwards, we will face a situation 
            // that pinchBy() is called without any pinchBegin(). 
            // To solve this problem, we call pinchBegin() here if it is never called. 
            if (!mPinchEventSent) {
                mContentViewCore.getContentViewGestureHandler().pinchBegin(detector.getEventTime(),
                        (int) detector.getFocusX(), (int) detector.getFocusY());
                mPinchEventSent = true;
            } 
            mContentViewCore.getContentViewGestureHandler().pinchBy(
                    detector.getEventTime(), (int) detector.getFocusX(), (int) detector.getFocusY(),
                    detector.getScaleFactor());
            return true; 
        } 
 
        private boolean ignoreDetectorEvents() { 
            return mPermanentlyIgnoreDetectorEvents ||
                    mTemporarilyIgnoreDetectorEvents ||
                    !mContentViewCore.isAlive();
        } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isInProgress, onTouchEvent
        mRender.loadA3DFile(path);
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isInProgress, onTouchEvent
    } 
 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getCurrentSpan, getFocusX, getFocusY, getPreviousSpan, getScaleFactor
		 
		@SuppressWarnings( "unused" ) 
		@Override 
		public boolean onScale( ScaleGestureDetector detector )
		{ 
			float span = detector.getCurrentSpan() - detector.getPreviousSpan();
			float targetScale = mCurrentScaleFactor * detector.getScaleFactor();
			if ( true ) { 
				targetScale = Math.min( getMaxZoom(), Math.max( targetScale, MIN_ZOOM ) );
				zoomTo( targetScale, detector.getFocusX(), detector.getFocusY() );
				mCurrentScaleFactor = Math.min( getMaxZoom(), Math.max( targetScale, MIN_ZOOM ) );
				mDoubleTapDirection = 1;
				invalidate(); 
				return true; 
			} 
			return false; 
		} 
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getFocusX, getFocusY, getScaleFactor
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android ScaleGestureDetector Questions & Answers:

Other Android ScaleGestureDetector Examples

34:		int oldMeasuredWidth, oldMeasuredHeight;
35:	
36:		ScaleGestureDetector mScaleDetector;
37:	
38:		Context context;

Read More

See Code Examples for Android ScaleGestureDetector Methods: