fix: make updateAnimation synchronized
This commit is contained in:
parent
4aae6c0a09
commit
8cc115a108
@ -21,9 +21,9 @@ public class MapAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final int ANIM_NONE = 0;
|
private final int ANIM_NONE = 0;
|
||||||
private final int ANIM_MOVE = 1 << 1;
|
private final int ANIM_MOVE = 1 << 0;
|
||||||
private final int ANIM_SCALE = 1 << 2;
|
private final int ANIM_SCALE = 1 << 1;
|
||||||
private final int ANIM_FLING = 1 << 3;
|
private final int ANIM_FLING = 1 << 2;
|
||||||
|
|
||||||
private final Map mMap;
|
private final Map mMap;
|
||||||
private final Viewport mViewport;
|
private final Viewport mViewport;
|
||||||
@ -166,12 +166,14 @@ public class MapAnimator {
|
|||||||
/**
|
/**
|
||||||
* called by MapRenderer at begin of each frame.
|
* called by MapRenderer at begin of each frame.
|
||||||
*/
|
*/
|
||||||
public void updateAnimation() {
|
public synchronized void updateAnimation() {
|
||||||
if (mState == ANIM_NONE)
|
if (mState == ANIM_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long millisLeft = mAnimEnd - MapRenderer.frametime;
|
long millisLeft = mAnimEnd - MapRenderer.frametime;
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
synchronized (mViewport) {
|
synchronized (mViewport) {
|
||||||
|
|
||||||
// cancel animation when position was changed since last
|
// cancel animation when position was changed since last
|
||||||
@ -200,8 +202,6 @@ public class MapAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float adv = FastMath.clamp(1.0f - millisLeft / mDuration, 0, 1);
|
float adv = FastMath.clamp(1.0f - millisLeft / mDuration, 0, 1);
|
||||||
boolean changed = false;
|
|
||||||
|
|
||||||
|
|
||||||
if ((mState & ANIM_SCALE) != 0) {
|
if ((mState & ANIM_SCALE) != 0) {
|
||||||
if (mScaleBy > 0)
|
if (mScaleBy > 0)
|
||||||
@ -218,11 +218,6 @@ public class MapAnimator {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (mAnimMove && mAnimScale) {
|
|
||||||
// mPos.angle = mStartPos.angle * (1 - adv);
|
|
||||||
// updateMatrix();
|
|
||||||
//}
|
|
||||||
|
|
||||||
if ((mState & ANIM_FLING) != 0) {
|
if ((mState & ANIM_FLING) != 0) {
|
||||||
adv = (float) Math.sqrt(adv);
|
adv = (float) Math.sqrt(adv);
|
||||||
double dx = mVelocity.x * adv;
|
double dx = mVelocity.x * adv;
|
||||||
@ -236,6 +231,11 @@ public class MapAnimator {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// remember current map position
|
||||||
|
mViewport.getMapPosition(mPos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// continue animation
|
// continue animation
|
||||||
if (changed) {
|
if (changed) {
|
||||||
// render and inform layers that position has changed
|
// render and inform layers that position has changed
|
||||||
@ -245,9 +245,6 @@ public class MapAnimator {
|
|||||||
mMap.render();
|
mMap.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// remember current map position
|
|
||||||
mViewport.getMapPosition(mPos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doScale(double newScale) {
|
private void doScale(double newScale) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user