Try to fix NPE while animating thread

Conflicts:
	OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java
This commit is contained in:
Victor Shcherb 2017-05-29 22:25:18 +02:00
parent fa407ef386
commit 82512864c5

View file

@ -90,18 +90,19 @@ public class AnimateDraggingMapThread {
public void stopAnimatingSync(){ public void stopAnimatingSync(){
// wait until current thread != null // wait until current thread != null
stopped = true; stopped = true;
while(currentThread != null){ Thread tt = null;
while((tt = currentThread) != null){
try { try {
currentThread.join(); tt.join();
} catch (InterruptedException e) { } catch (Exception e) {
} }
} }
} }
public void startThreadAnimating(final Runnable runnable){ public synchronized void startThreadAnimating(final Runnable runnable){
stopAnimatingSync(); stopAnimatingSync();
stopped = false; stopped = false;
currentThread = new Thread(new Runnable() { final Thread t = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -114,8 +115,8 @@ public class AnimateDraggingMapThread {
} }
} }
}, "Animating Thread"); }, "Animating Thread");
currentThread.start(); currentThread = t;
t.start();
} }
public void startMoving(final double finalLat, final double finalLon, final Pair<Integer, Double> finalZoom, public void startMoving(final double finalLat, final double finalLon, final Pair<Integer, Double> finalZoom,