Try to fix NPE while animating thread

This commit is contained in:
Victor Shcherb 2017-05-29 22:25:18 +02:00
parent 5c0259d8e8
commit f224b8b758

View file

@ -90,22 +90,25 @@ public class AnimateDraggingMapThread {
public void stopAnimatingSync(){
// wait until current thread != null
stopped = true;
while(currentThread != null){
Thread tt = null;
while((tt = currentThread) != null){
try {
currentThread.join();
tt.join();
} catch (Exception e) {
}
}
}
public void startThreadAnimating(final Runnable runnable){
public synchronized void startThreadAnimating(final Runnable runnable){
stopAnimatingSync();
stopped = false;
currentThread = new Thread(new Runnable() {
final Thread[] t = new Thread[1];
t[0] = new Thread(new Runnable() {
@Override
public void run() {
try {
currentThread = t[0];
suspendUpdate();
runnable.run();
} finally {
@ -114,7 +117,7 @@ public class AnimateDraggingMapThread {
}
}
}, "Animating Thread");
currentThread.start();
t[0].start();
}