use of org.odk.collect.android.fragments.dialogs.ResetSettingsResultDialog in project collect by opendatakit.
the class ResetDialogPreferenceFragmentCompat method handleResult.
private void handleResult(final List<Integer> resetActions, List<Integer> failedResetActions) {
final StringBuilder resultMessage = new StringBuilder();
for (int action : resetActions) {
switch(action) {
case RESET_PREFERENCES:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_settings_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_settings_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_INSTANCES:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_saved_forms_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_saved_forms_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_FORMS:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_blank_forms_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_blank_forms_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_CACHE:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_cache_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_cache_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_LAYERS:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_layers_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_layers_result), context.getString(R.string.success)));
}
break;
}
if (resetActions.indexOf(action) < resetActions.size() - 1) {
resultMessage.append("\n\n");
}
}
if (!((CollectAbstractActivity) context).isInstanceStateSaved()) {
((CollectAbstractActivity) context).runOnUiThread(() -> {
if (resetActions.contains(RESET_PREFERENCES)) {
((CollectAbstractActivity) context).recreate();
}
ResetSettingsResultDialog resetSettingsResultDialog = ResetSettingsResultDialog.newInstance(String.valueOf(resultMessage));
try {
resetSettingsResultDialog.show(((CollectAbstractActivity) context).getSupportFragmentManager(), RESET_SETTINGS_RESULT_DIALOG_TAG);
} catch (ClassCastException e) {
Timber.i(e);
}
});
}
context = null;
}
Aggregations