public class CustomScaleGesture
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
CustomScaleGesture.OnScaleGestureListener |
static class |
CustomScaleGesture.SimpleOnScaleGestureListener
A convenience class to extend when you only want to listen for a subset
of scaling-related events.
|
Constructor and Description |
---|
CustomScaleGesture(android.content.Context context,
CustomScaleGesture.OnScaleGestureListener listener)
Creates a ScaleGestureDetector with the supplied listener.
|
CustomScaleGesture(android.content.Context context,
CustomScaleGesture.OnScaleGestureListener listener,
android.os.Handler handler)
Creates a ScaleGestureDetector with the supplied listener.
|
Modifier and Type | Method and Description |
---|---|
float |
getCurrentSpan()
Return the average distance between each of the pointers forming the
gesture in progress through the focal point.
|
float |
getCurrentSpanX()
Return the average X distance between each of the pointers forming the
gesture in progress through the focal point.
|
float |
getCurrentSpanY()
Return the average Y distance between each of the pointers forming the
gesture in progress through the focal point.
|
long |
getEventTime()
Return the event time of the current event being processed.
|
float |
getFocusX()
Get the X coordinate of the current gesture's focal point.
|
float |
getFocusY()
Get the Y coordinate of the current gesture's focal point.
|
float |
getPreviousSpan()
Return the previous average distance between each of the pointers forming the
gesture in progress through the focal point.
|
float |
getPreviousSpanX()
Return the previous average X distance between each of the pointers forming the
gesture in progress through the focal point.
|
float |
getPreviousSpanY()
Return the previous average Y distance between each of the pointers forming the
gesture in progress through the focal point.
|
float |
getScaleFactor()
Return the scaling factor from the previous scale event to the current
event.
|
long |
getTimeDelta()
Return the time difference in milliseconds between the previous
accepted scaling event and the current scaling event.
|
boolean |
isInProgress()
Returns
true if a scale gesture is in progress. |
boolean |
isQuickScaleEnabled()
Return whether the quick scale gesture, in which the user performs a double tap followed by a
swipe, should perform scaling.
|
boolean |
isStylusScaleEnabled()
Return whether the stylus scale gesture, in which the user uses a stylus and presses the
button, should perform scaling.
|
boolean |
onTouchEvent(android.view.MotionEvent event)
Accepts MotionEvents and dispatches events to a
ScaleGestureDetector.OnScaleGestureListener
when appropriate. |
void |
setQuickScaleEnabled(boolean scales)
Set whether the associated
ScaleGestureDetector.OnScaleGestureListener should receive onScale callbacks
when the user performs a doubleTap followed by a swipe. |
void |
setStylusScaleEnabled(boolean scales)
Sets whether the associates
ScaleGestureDetector.OnScaleGestureListener should receive
onScale callbacks when the user uses a stylus and presses the button. |
public CustomScaleGesture(android.content.Context context, CustomScaleGesture.OnScaleGestureListener listener)
Looper
thread.context
- the application's contextlistener
- the listener invoked for all the callbacks, this must
not be null.java.lang.NullPointerException
- if listener
is null.public CustomScaleGesture(android.content.Context context, CustomScaleGesture.OnScaleGestureListener listener, android.os.Handler handler)
context
- the application's contextlistener
- the listener invoked for all the callbacks, this must
not be null.handler
- the handler to use for running deferred listener events.java.lang.NullPointerException
- if listener
is null.Handler.Handler()
public boolean onTouchEvent(android.view.MotionEvent event)
ScaleGestureDetector.OnScaleGestureListener
when appropriate.
Applications should pass a complete and consistent event stream to this method. A complete and consistent event stream involves all MotionEvents from the initial ACTION_DOWN to the final ACTION_UP or ACTION_CANCEL.
event
- The event to processpublic void setQuickScaleEnabled(boolean scales)
ScaleGestureDetector.OnScaleGestureListener
should receive onScale callbacks
when the user performs a doubleTap followed by a swipe. Note that this is enabled by default
if the app targets API 19 and newer.scales
- true to enable quick scaling, false to disablepublic boolean isQuickScaleEnabled()
setQuickScaleEnabled(boolean)
.public void setStylusScaleEnabled(boolean scales)
ScaleGestureDetector.OnScaleGestureListener
should receive
onScale callbacks when the user uses a stylus and presses the button.
Note that this is enabled by default if the app targets API 23 and newer.scales
- true to enable stylus scaling, false to disable.public boolean isStylusScaleEnabled()
setStylusScaleEnabled(boolean)
public boolean isInProgress()
true
if a scale gesture is in progress.public float getFocusX()
If isInProgress()
would return false, the result of this
function is undefined.
public float getFocusY()
If isInProgress()
would return false, the result of this
function is undefined.
public float getCurrentSpan()
public float getCurrentSpanX()
public float getCurrentSpanY()
public float getPreviousSpan()
public float getPreviousSpanX()
public float getPreviousSpanY()
public float getScaleFactor()
getCurrentSpan()
/ getPreviousSpan()
).public long getTimeDelta()
public long getEventTime()