public class ViewPositionAnimator
extends java.lang.Object
ImageView) to any gestures controlled
view implementing GestureView (e.g. GestureImageView).
Note, that initial and final views should have same aspect ratio for correct animation.
In case of ImageView initial and final images should have same aspect, but actual views
can have different aspects (e.g. animating from square thumb view with scale type
ImageView.ScaleType.CENTER_CROP to rectangular full image view).
To use this class first create an instance and then call enter(View, boolean).enter(ViewPosition, boolean) method. exit(boolean) method.addPositionUpdateListener(PositionUpdateListener).update(View) method to update to new view.
You can also manually update initial view position using update(ViewPosition) method.| Modifier and Type | Class and Description |
|---|---|
static interface |
ViewPositionAnimator.PositionUpdateListener |
| Constructor and Description |
|---|
ViewPositionAnimator(GestureView to) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPositionUpdateListener(ViewPositionAnimator.PositionUpdateListener listener)
Adds listener to the set of position updates listeners that will be notified during
any position changes.
|
void |
enter(boolean withAnimation)
Starts 'enter' animation from no specific position (position will be calculated based on
gravity set in
Settings). |
void |
enter(android.view.View from,
boolean withAnimation)
Starts 'enter' animation from
from view to to. |
void |
enter(ViewPosition fromPos,
boolean withAnimation)
Starts 'enter' animation from
from position to to view. |
void |
exit(boolean withAnimation)
Starts 'exit' animation from
to view back to from. |
long |
getDuration()
Deprecated.
Use
Settings.getAnimationsDuration() instead. |
float |
getPosition() |
float |
getPositionState()
Deprecated.
Use
getPosition() method instead. |
float |
getToPosition() |
boolean |
isAnimating()
Whether view position animation is in progress or not.
|
boolean |
isLeaving() |
void |
removePositionUpdateListener(ViewPositionAnimator.PositionUpdateListener listener)
Removes listener added by
addPositionUpdateListener(PositionUpdateListener). |
void |
setDuration(long duration)
Deprecated.
Use
Settings.setAnimationsDuration(long) instead. |
void |
setState(float pos,
boolean leaving,
boolean animate)
Stops current animation and sets position state to particular values.
|
void |
setToState(State state,
float position)
Specifies target (to) state and it's position which will be used to interpolate
current state for intermediate positions (i.e.
|
void |
stopAnimation()
Stops current animation, if any.
|
void |
update(android.view.View from)
Updates initial view in case it was changed.
|
void |
update(ViewPosition from)
Updates position of initial view in case it was changed.
|
void |
updateToNone()
Updates position of initial view to no specific position, in case 'to' view is not available
anymore.
|
public ViewPositionAnimator(GestureView to)
public void enter(boolean withAnimation)
Settings).
Note, that in most cases you should use enter(View, boolean) or
enter(ViewPosition, boolean) methods instead.public void enter(android.view.View from,
boolean withAnimation)
from view to to.
Note, if from view was changed (i.e. during list adapter refresh) you should
update to new view using update(View) method.public void enter(ViewPosition fromPos, boolean withAnimation)
from position to to view.
Note, if from view position was changed (i.e. during list adapter refresh) you
should update to new view using update(ViewPosition) method.public void update(android.view.View from)
public void update(ViewPosition from)
public void updateToNone()
public void exit(boolean withAnimation)
to view back to from.public void addPositionUpdateListener(ViewPositionAnimator.PositionUpdateListener listener)
public void removePositionUpdateListener(ViewPositionAnimator.PositionUpdateListener listener)
addPositionUpdateListener(PositionUpdateListener).
Note, this method may be called inside listener's callback without throwing
IndexOutOfBoundsException.@Deprecated public long getDuration()
Settings.getAnimationsDuration() instead.@Deprecated public void setDuration(long duration)
Settings.setAnimationsDuration(long) instead.public float getToPosition()
setToState(State, float).
Maybe useful to determine real animation position during exit gesture.
I.e. getPosition() / getToPosition() (changes from 0 to ∞)
represents interpolated position used to calculate intermediate state and bounds.public float getPosition()
[0, 1], where 0 is for
initial (from) position and 1 is for final (to) position.
Note, that final position can be changed by setToState(State, float), so if you
need to have real value of final position (instead of 1) then you need to use
getToPosition() method.@Deprecated public float getPositionState()
getPosition() method instead.public boolean isLeaving()
public void setToState(State state, float position)
getPosition()).
Only use this method if you understand what you do.getToPosition()public void setState(float pos,
boolean leaving,
boolean animate)
state = 0f and isLeaving = true
it will cleanup all internal stuff. So you will need to call enter(View, boolean)
or enter(ViewPosition, boolean) again in order to continue using animator.public boolean isAnimating()
public void stopAnimation()