Commit e64f1b93 authored by leslie0216's avatar leslie0216
Browse files

-avoid init experiment twice

-change message when send/receive ball
parent 7de8ebff
......@@ -255,7 +255,7 @@ public class MainActivity extends ActionBarActivity implements NfcAdapter.Create
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_SENT:
Toast.makeText(getApplicationContext(), "Ball sent!", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Ball has been sent!", Toast.LENGTH_SHORT).show();
m_mainView.removeBalls();
m_mainView.endTrail();
m_mainView.invalidate();
......@@ -415,7 +415,7 @@ public class MainActivity extends ActionBarActivity implements NfcAdapter.Create
runOnUiThread(new Runnable() {
@Override
public void run() {
showToast("received ball");
showToast("Received ball!");
m_mainView.invalidate();
}
});
......
......@@ -70,6 +70,8 @@ public class MainView extends View {
private MainLogger m_logger;
private MainLogger m_receiveLogger;
private boolean m_isExperimentInitialised;
/**
* experiment end
*/
......@@ -93,6 +95,8 @@ public class MainView extends View {
m_ballBornX = displayMetrics.widthPixels * 0.5f;
m_ballBornY = displayMetrics.heightPixels * 0.75f - m_ballRadius * 2.0f;
m_isExperimentInitialised = false;
//addBall();
}
......@@ -194,7 +198,7 @@ public class MainView extends View {
/**
* experiment end
*/
if (m_remotePhones.size() == m_experimentPhoneNumber) {
if (m_remotePhones.size() == m_experimentPhoneNumber && !m_isExperimentInitialised) {
initExperiment();
}
/**
......@@ -418,6 +422,8 @@ public class MainView extends View {
* experiment begin
*/
private void initExperiment() {
m_isExperimentInitialised = true;
// init ball names
m_ballNames = new ArrayList<>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment