Skip to content

Commit

Permalink
Merge pull request #667 from opensrp/fix_tech_debt_660
Browse files Browse the repository at this point in the history
Add tests for setUpOptiBpActivityResultListener
  • Loading branch information
SebaMutuku authored Sep 12, 2023
2 parents e9eaac7 + 3fc8d2d commit 04c125e
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,14 @@ protected void addOnBarCodeResultListeners(final Context context, final Material
if (context instanceof JsonApi) {
JsonApi jsonApi = (JsonApi) context;
jsonApi.addOnActivityResultListener(JsonFormConstants.BARCODE_CONSTANTS.BARCODE_REQUEST_CODE,
new OnActivityResultListener() {
@Override
public void onActivityResult(int requestCode,
int resultCode, Intent data) {
if (requestCode == JsonFormConstants.BARCODE_CONSTANTS.BARCODE_REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null) {
Barcode barcode = data.getParcelableExtra(JsonFormConstants.BARCODE_CONSTANTS.BARCODE_KEY);
Timber.d("Scanned QR Code %s ", barcode.displayValue);
editText.setText(barcode.displayValue);
} else
Timber.i("NO RESULT FOR QR CODE");
}
(requestCode, resultCode, data) -> {
if (requestCode == JsonFormConstants.BARCODE_CONSTANTS.BARCODE_REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null) {
Barcode barcode = data.getParcelableExtra(JsonFormConstants.BARCODE_CONSTANTS.BARCODE_KEY);
Timber.d("Scanned QR Code %s ", barcode.displayValue);
editText.setText(barcode.displayValue);
} else
Timber.i("NO RESULT FOR QR CODE");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,17 @@ private void addFingerprintResultsListener(final Context context, final ImageVie
if (context instanceof JsonApi) {
JsonApi jsonApi = (JsonApi) context;
jsonApi.addOnActivityResultListener(JsonFormConstants.ACTIVITY_REQUEST_CODE.REQUEST_CODE_REGISTER,
new OnActivityResultListener() {
@Override
public void onActivityResult(int requestCode,
int resultCode, Intent data) {
if (requestCode == JsonFormConstants.ACTIVITY_REQUEST_CODE.REQUEST_CODE_REGISTER && resultCode == RESULT_OK) {
if (data != null) {

SimPrintsRegistration registration = (SimPrintsRegistration) data.getSerializableExtra(SimPrintsConstantHelper.INTENT_DATA);
imageView.setTag(R.id.simprints_guid, registration.getGuid());
setFingerprintDrawable(context, imageView, registration.getGuid(), true);
Timber.d("Scanned Fingerprint GUID %s ", registration.getGuid());
} else {
Timber.i("NO RESULT FOR FINGERPRINT");
setFingerprintDrawable(context, imageView, "", true);
}
(requestCode, resultCode, data) -> {
if (requestCode == JsonFormConstants.ACTIVITY_REQUEST_CODE.REQUEST_CODE_REGISTER && resultCode == RESULT_OK) {
if (data != null) {

SimPrintsRegistration registration = (SimPrintsRegistration) data.getSerializableExtra(SimPrintsConstantHelper.INTENT_DATA);
imageView.setTag(R.id.simprints_guid, registration.getGuid());
setFingerprintDrawable(context, imageView, registration.getGuid(), true);
Timber.d("Scanned Fingerprint GUID %s ", registration.getGuid());
} else {
Timber.i("NO RESULT FOR FINGERPRINT");
setFingerprintDrawable(context, imageView, "", true);
}
}
});
Expand Down
Loading

0 comments on commit 04c125e

Please sign in to comment.