use of com.nightscout.core.preferences.NightscoutPreferences in project android-uploader by nightscout.
the class SyncingService method startActionSingleSync.
/**
* Starts this service to perform action Single Sync with the given parameters. If
* the service is already performing a task this action will be queued.
*
* @see IntentService
*/
public static void startActionSingleSync(Context context, int numOfPages) {
NightscoutPreferences preferences = new AndroidPreferences(context);
// Exit if the user hasn't selected "I understand"
if (!preferences.getIUnderstand()) {
Toast.makeText(context, R.string.message_user_not_understand, Toast.LENGTH_LONG).show();
return;
}
Intent intent = new Intent(context, SyncingService.class);
intent.setAction(ACTION_SYNC);
intent.putExtra(SYNC_PERIOD, numOfPages);
context.startService(intent);
}
use of com.nightscout.core.preferences.NightscoutPreferences 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