Lobby controller list view is able to react to changes in client state boats and update the list view appropriately.

#story[1055]
This commit is contained in:
Zhi You Tan
2017-07-24 11:15:10 +12:00
parent 9d754c8819
commit df2efa3329
8 changed files with 609 additions and 27 deletions
@@ -1,10 +1,10 @@
package seng302.client;
import java.util.List;
import java.util.Observable;
/**
* Created by zyt10 on 21/07/17.
* Used by LobbyController to run a separate thread-loop
* updates the controller when change is detected.
*/
public class ClientStateQueryingRunnable extends Observable implements Runnable {
@@ -15,9 +15,21 @@ public class ClientStateQueryingRunnable extends Observable implements Runnable
@Override
public void run() {
while(!terminate) {
if (ClientState.isRaceStarted() && ClientState.isConnectedToHost()) {
// if (ClientState.isRaceStarted() && ClientState.isConnectedToHost()) {
// setChanged();
// notifyObservers();
// }
// Sleeping the thread so it will respond to the if statement below
// if you know a better fix, pls tell me :) -ryan
try {
Thread.sleep(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (ClientState.isDirtyState()) {
setChanged();
notifyObservers();
ClientState.setDirtyState(false);
}
}
}