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 than 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(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() |
float |
getPositionState() |
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) |
void |
setState(float state,
boolean isLeaving,
boolean isAnimating)
Stops current animation and sets position state to particular values.
|
void |
stopAnimation()
Stops current animation, if any.
|
void |
update(android.view.View from)
Updates initial view in case it was changed.
|
void |
update(ViewPosition fromPos)
Updates position of initial view in case it was changed.
|
public ViewPositionAnimator(GestureView to)
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 fromPos)
public void exit(boolean withAnimation)
to view back to frompublic 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.public long getDuration()
public void setDuration(long duration)
public float getPositionState()
[0, 1], where 0 is for
initial (from) position and 1 is for final (to) position.public boolean isLeaving()
public void setState(float state,
boolean isLeaving,
boolean isAnimating)
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()