Try to fix NPE while animating thread
This commit is contained in:
parent
5c0259d8e8
commit
f224b8b758
1 changed files with 8 additions and 5 deletions
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue