use of com.nightscout.core.barcode.NSBarcodeConfig in project android-uploader by nightscout.
the class SettingsActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
NightscoutPreferences prefs = new AndroidPreferences(this);
if (scanResult != null && scanResult.getContents() != null) {
NSBarcodeConfig barcode = new NSBarcodeConfig(scanResult.getContents());
if (barcode.hasMongoConfig()) {
prefs.setMongoUploadEnabled(true);
if (barcode.getMongoUri().isPresent()) {
prefs.setMongoClientUri(barcode.getMongoUri().get());
prefs.setMongoCollection(barcode.getMongoCollection().orNull());
prefs.setMongoDeviceStatusCollection(barcode.getMongoDeviceStatusCollection().orNull());
}
} else {
prefs.setMongoUploadEnabled(false);
}
if (barcode.hasApiConfig()) {
prefs.setRestApiEnabled(true);
prefs.setRestApiBaseUris(barcode.getApiUris());
} else {
prefs.setRestApiEnabled(false);
}
refreshFragments();
}
}
Aggregations