use of com.github.dedis.popstellar.SingleEvent in project popstellar by dedis.
the class LaoDetailViewModel method onQRCodeDetected.
@Override
public void onQRCodeDetected(Barcode barcode) {
Log.d(TAG, "Detected barcode with value: " + barcode.rawValue);
PublicKey attendee;
try {
attendee = new PublicKey(barcode.rawValue);
} catch (IllegalArgumentException e) {
mScanWarningEvent.postValue(new SingleEvent<>("Invalid QR code. Please try again."));
return;
}
if (attendees.contains(attendee) || Objects.requireNonNull(mWitnesses.getValue()).contains(attendee)) {
mScanWarningEvent.postValue(new SingleEvent<>("This QR code has already been scanned. Please try again."));
return;
}
if (scanningAction == (ScanningAction.ADD_ROLL_CALL_ATTENDEE)) {
attendees.add(attendee);
mAttendeeScanConfirmEvent.postValue(new SingleEvent<>("Attendee has been added."));
mNbAttendeesEvent.postValue(new SingleEvent<>(attendees.size()));
} else if (scanningAction == (ScanningAction.ADD_WITNESS)) {
witnesses.add(attendee);
mWitnessScanConfirmEvent.postValue(new SingleEvent<>(true));
updateLaoWitnesses();
}
}
Aggregations