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(){
|
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 (Exception 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[1];
|
||||||
|
t[0] = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
currentThread = t[0];
|
||||||
suspendUpdate();
|
suspendUpdate();
|
||||||
runnable.run();
|
runnable.run();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -114,7 +117,7 @@ public class AnimateDraggingMapThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Animating Thread");
|
}, "Animating Thread");
|
||||||
currentThread.start();
|
t[0].start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue