Search in sources :

Example 1 with NSBarcodeConfig

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();
    }
}
Also used : AndroidPreferences(com.nightscout.android.preferences.AndroidPreferences) IntentResult(com.google.zxing.integration.android.IntentResult) NightscoutPreferences(com.nightscout.core.preferences.NightscoutPreferences) NSBarcodeConfig(com.nightscout.core.barcode.NSBarcodeConfig)

Aggregations

IntentResult (com.google.zxing.integration.android.IntentResult)1 AndroidPreferences (com.nightscout.android.preferences.AndroidPreferences)1 NSBarcodeConfig (com.nightscout.core.barcode.NSBarcodeConfig)1 NightscoutPreferences (com.nightscout.core.preferences.NightscoutPreferences)1