Commit 809b6e79 authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Fix QR checker action not working

parent 4c765630
......@@ -81,7 +81,7 @@ public class MainActivity extends AppCompatActivity {
OpenNodes = new ArrayList<Node>();
ArrayList<Action> A1 = new ArrayList<Action>();
A1.add(new TTSReading(this, 1, "Test 1 aaa test 1"));
A1.add(new TTSReading(this, 1, "Bonjour"));
A1.add(new RemoveAtom(this,1, new ItemAtom(0)));
A1.add(new AddAtom(this,1, new ItemAtom(1)));
A1.add(new ClearNodes(this,1));
......@@ -124,7 +124,7 @@ public class MainActivity extends AppCompatActivity {
}
public void CheckOpenNodes() {
// mainThread.run();
mainThread.run();
}
public Node GetNode(int ID)
......@@ -269,7 +269,7 @@ public class MainActivity extends AppCompatActivity {
Snackbar.make(findViewById(R.id.main_layout), "QR code says:" + data.getStringExtra("QR_CONTENT") , Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
QRActionRequesting.GiveQRResult(data.getStringExtra("QR_CONTENT"));
if(QRActionRequesting != null) QRActionRequesting.GiveQRResult(data.getStringExtra("QR_CONTENT"));
}
public void SetListeningResults(String result) // to display listening results
......
package com.example.qrquest.actions;
import android.util.Log;
import com.example.qrquest.MainActivity;
import com.example.qrquest.atom.QRAtom;
......@@ -20,6 +22,7 @@ public class CaptureQR extends Action {
public void GiveQRResult(String result)
{
Log.d("Debug2", "CaptureQR action received QR: " + result);
mainActivity.Atoms.add(new QRAtom(result));
End();
}
......
package com.example.qrquest.actions;
import android.util.Log;
import com.example.qrquest.MainActivity;
import com.example.qrquest.atom.Atom;
import com.example.qrquest.atom.QRAtom;
......@@ -19,9 +21,11 @@ public class QRChecker extends Action {
super.Do();
for (Atom a: mainActivity.Atoms
) {
Log.d("Debug2","QR checker action reads " + a.GetStringValue());
if(a.getClass() == QRAtom.class)
{
if(a.GetStringValue() == WaitedValue) mainActivity.OpenNodes.add(mainActivity.GetNode(SuccessNodeID));
Log.d("Debug2","QR checker detected a QRAtom");
if(a.GetStringValue().equals(WaitedValue)) mainActivity.OpenNodes.add(mainActivity.GetNode(SuccessNodeID));
else mainActivity.OpenNodes.add(mainActivity.GetNode(FailNodeID));
mainActivity.Atoms.remove(a);
}
......
Markdown is supported
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