public class GestureController
extends java.lang.Object
implements android.view.View.OnTouchListener
State) based on current
setup (Settings).getSettings().Settings.
This class implements View.OnTouchListener to delegate touches from view to controller.
State can also be manipulated directly with getState(), updateState()
and resetState(). You can also access getStateController() for some additional
stuff.
State can be animated with animateStateTo(State) method.stopFlingAnimation(), stopStateAnimation()
and stopAllAnimations() methods.
All state changes will be passed to OnStateChangeListener.
See addOnStateChangeListener and
removeOnStateChangeListener methods.
Additional touch events can be listened with OnGestureListener and
SimpleOnGestureListener using
setOnGesturesListener method.
| Modifier and Type | Class and Description |
|---|---|
static interface |
GestureController.OnGestureListener
Listener for different touch events
|
static interface |
GestureController.OnStateChangeListener
State changes listener
|
static class |
GestureController.SimpleOnGestureListener
Simple implementation of
GestureController.OnGestureListener |
| Constructor and Description |
|---|
GestureController(android.view.View view) |
| Modifier and Type | Method and Description |
|---|---|
void |
addOnStateChangeListener(GestureController.OnStateChangeListener listener)
Adds listener for state changes.
|
void |
animateStateTo(State endState)
Animates current state to provided end state.
|
Settings |
getSettings()
Returns settings that can be updated.
|
State |
getState()
Returns current state.
|
StateController |
getStateController()
Returns state controller that can be used externally.
|
protected void |
notifyStateReset() |
protected void |
notifyStateUpdated() |
protected boolean |
onDoubleTapEvent(android.view.MotionEvent e) |
protected boolean |
onDown(android.view.MotionEvent e) |
protected boolean |
onFling(android.view.MotionEvent e1,
android.view.MotionEvent e2,
float vX,
float vY) |
protected void |
onFlingAnimationFinished() |
protected void |
onFlingScroll(float fromX,
float fromY,
float toX,
float toY) |
protected void |
onLongPress(android.view.MotionEvent e) |
protected boolean |
onRotate(RotationGestureDetector detector) |
protected boolean |
onRotationBegin(RotationGestureDetector detector) |
protected void |
onRotationEnd(RotationGestureDetector detector) |
protected boolean |
onScale(android.view.ScaleGestureDetector detector) |
protected boolean |
onScaleBegin(android.view.ScaleGestureDetector detector) |
protected void |
onScaleEnd(android.view.ScaleGestureDetector detector) |
protected boolean |
onScroll(android.view.MotionEvent e1,
android.view.MotionEvent e2,
float dX,
float dY) |
protected boolean |
onSingleTapConfirmed(android.view.MotionEvent e) |
protected boolean |
onSingleTapUp(android.view.MotionEvent e) |
protected void |
onStateAnimationFinished() |
boolean |
onTouch(android.view.View view,
android.view.MotionEvent event) |
protected void |
onUpOrCancel(android.view.MotionEvent e) |
void |
removeOnStateChangeListener(GestureController.OnStateChangeListener listener)
Removes listener for state changes.
|
void |
resetState()
Resets to initial state (default position, min zoom level) and notifies
GestureController.OnStateChangeListener listeners. |
void |
setLongPressEnabled(boolean enabled)
Sets whether long press is enabled or not.
|
void |
setOnGesturesListener(GestureController.OnGestureListener listener)
Sets listener for basic touch events.
|
void |
stopAllAnimations() |
void |
stopFlingAnimation() |
void |
stopStateAnimation() |
void |
updateState()
Applies state restrictions and notifies
GestureController.OnStateChangeListener listeners. |
public void setOnGesturesListener(GestureController.OnGestureListener listener)
GestureController.OnGestureListenerpublic void addOnStateChangeListener(GestureController.OnStateChangeListener listener)
GestureController.OnStateChangeListenerpublic void removeOnStateChangeListener(GestureController.OnStateChangeListener listener)
addOnStateChangeListener(OnStateChangeListener)public void setLongPressEnabled(boolean enabled)
GestureController.OnGestureListener.onLongPress(android.view.MotionEvent)public Settings getSettings()
updateState() or resetState() after settings was changed
to correctly apply state restrictions.public State getState()
StateController instead.
If current state was changed outside GestureController
you should call updateState() to properly apply changes.public StateController getStateController()
public void updateState()
GestureController.OnStateChangeListener listeners.public void resetState()
GestureController.OnStateChangeListener listeners.
Should be called when image size is changed.
See Settings.setImage(int, int).public void animateStateTo(State endState)
public void stopStateAnimation()
public void stopFlingAnimation()
public void stopAllAnimations()
protected void notifyStateUpdated()
protected void notifyStateReset()
public boolean onTouch(android.view.View view,
android.view.MotionEvent event)
onTouch in interface android.view.View.OnTouchListenerprotected boolean onDown(android.view.MotionEvent e)
protected void onUpOrCancel(android.view.MotionEvent e)
protected boolean onSingleTapUp(android.view.MotionEvent e)
protected void onLongPress(android.view.MotionEvent e)
protected boolean onScroll(android.view.MotionEvent e1,
android.view.MotionEvent e2,
float dX,
float dY)
protected boolean onFling(android.view.MotionEvent e1,
android.view.MotionEvent e2,
float vX,
float vY)
protected void onFlingScroll(float fromX,
float fromY,
float toX,
float toY)
protected boolean onSingleTapConfirmed(android.view.MotionEvent e)
protected boolean onDoubleTapEvent(android.view.MotionEvent e)
protected boolean onScaleBegin(android.view.ScaleGestureDetector detector)
protected boolean onScale(android.view.ScaleGestureDetector detector)
protected void onScaleEnd(android.view.ScaleGestureDetector detector)
protected boolean onRotationBegin(RotationGestureDetector detector)
protected boolean onRotate(RotationGestureDetector detector)
protected void onRotationEnd(RotationGestureDetector detector)
protected void onFlingAnimationFinished()
protected void onStateAnimationFinished()