use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.
the class AppUpdateController method buildInstallFailedDialog.
private ConfirmationDialog buildInstallFailedDialog() {
dismissExistingDialog();
int headingResId = R.string.heading_install_app_failed;
int subHeadingResId = R.string.message_install_app_failed;
int positiveButtonTextResId = R.string.action_redownload_app;
int negativeButtonTextResId = allowDismiss ? R.string.action_redownload_app_later : R.string.action_close_app;
final ConfirmationDialog installFailedDialog = new ConfirmationDialog(activity, headingResId, subHeadingResId, positiveButtonTextResId, negativeButtonTextResId);
installFailedDialog.setCancelable(false);
installFailedDialog.setPositiveCallback(() -> downloadNewAppVersion());
if (allowDismiss) {
installFailedDialog.setNegativeCallback(dismissCallback);
} else {
installFailedDialog.setNegativeCallback(() -> ((SormasApplication) activity.getApplication()).closeApp(activity));
}
return installFailedDialog;
}
use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.
the class AppUpdateController method buildInstallNotPossibleDialog.
private ConfirmationDialog buildInstallNotPossibleDialog() {
dismissExistingDialog();
int headingResId = R.string.heading_install_app_failed;
int subHeadingResId = R.string.message_install_app_not_possible;
int positiveButtonTextResId = allowDismiss ? R.string.action_ok : R.string.action_close_app;
ConfirmationDialog installNotPossibleDialog = new ConfirmationDialog(activity, headingResId, subHeadingResId, positiveButtonTextResId, -1);
installNotPossibleDialog.setCancelable(false);
installNotPossibleDialog.getNegativeButton().setVisibility(GONE);
if (allowDismiss) {
installNotPossibleDialog.setPositiveCallback(dismissCallback);
} else {
installNotPossibleDialog.setPositiveCallback(() -> ((SormasApplication) activity.getApplication()).closeApp(activity));
}
return installNotPossibleDialog;
}
use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.
the class SettingsFragment method showRepullDataConfirmationDialog.
private void showRepullDataConfirmationDialog() {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_resync_duration);
confirmationDialog.setPositiveCallback(() -> {
// Collect unsynchronized changes
final List<Case> modifiedCases = DatabaseHelper.getCaseDao().getModifiedEntities();
final List<Contact> modifiedContacts = DatabaseHelper.getContactDao().getModifiedEntities();
final List<Person> modifiedPersons = DatabaseHelper.getPersonDao().getModifiedEntities();
final List<Event> modifiedEvents = DatabaseHelper.getEventDao().getModifiedEntities();
final List<EventParticipant> modifiedEventParticipants = DatabaseHelper.getEventParticipantDao().getModifiedEntities();
final List<Sample> modifiedSamples = DatabaseHelper.getSampleDao().getModifiedEntities();
final List<Visit> modifiedVisits = DatabaseHelper.getVisitDao().getModifiedEntities();
getBaseActivity().synchronizeData(SynchronizeDataAsync.SyncMode.CompleteAndRepull, true, true, null, new Callback() {
@Override
public void call() {
// Add deleted entities that had unsynchronized changes to sync log
for (Case caze : modifiedCases) {
if (DatabaseHelper.getCaseDao().queryUuidReference(caze.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(caze.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Contact contact : modifiedContacts) {
if (DatabaseHelper.getContactDao().queryUuidReference(contact.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(contact.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Person person : modifiedPersons) {
if (DatabaseHelper.getPersonDao().queryUuidReference(person.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(person.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Event event : modifiedEvents) {
if (DatabaseHelper.getEventDao().queryUuidReference(event.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(event.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (EventParticipant eventParticipant : modifiedEventParticipants) {
if (DatabaseHelper.getEventParticipantDao().queryUuidReference(eventParticipant.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(eventParticipant.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Sample sample : modifiedSamples) {
if (DatabaseHelper.getSampleDao().queryUuidReference(sample.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(sample.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Visit visit : modifiedVisits) {
if (DatabaseHelper.getVisitDao().queryUuidReference(visit.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(visit.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
}
}, new Callback() {
@Override
public void call() {
DatabaseHelper.clearTables(false);
}
});
});
confirmationDialog.show();
}
use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method showSubmitReportConfirmationDialog.
private void showSubmitReportConfirmationDialog() {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_report, R.string.action_cancel);
confirmationDialog.setPositiveCallback(() -> {
confirmReportTask = new DefaultAsyncTask(getContext()) {
@Override
public void onPreExecute() {
getBaseActivity().showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().build(getEpiWeek());
DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
super.onPostExecute(taskResult);
getBaseActivity().hidePreloader();
Intent intent = new Intent(getContext(), ReportActivity.class);
getContext().startActivity(intent);
if (!taskResult.getResultStatus().isSuccess()) {
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
return;
}
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_weekly_report_submitted);
}
}.executeOnThreadPool();
});
confirmationDialog.show();
}
use of de.symeda.sormas.app.component.dialog.ConfirmationDialog in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsFragment method showSubmitCaseNumbersConfirmationDialog.
private void showSubmitCaseNumbersConfirmationDialog() {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_case_numbers, R.string.action_cancel);
confirmationDialog.setPositiveCallback(() -> {
confirmCaseNumbersTask = new DefaultAsyncTask(getContext()) {
@Override
public void onPreExecute() {
getBaseActivity().showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
for (AggregateReport report : reports) {
// Don't save if a generated report has no case numbers
if (report.getLocalChangeDate() == null && (report.getNewCases() == null || report.getNewCases() == 0) && (report.getLabConfirmations() == null || report.getLabConfirmations() == 0) && (report.getDeaths() == null || report.getDeaths() == 0)) {
continue;
}
if (report.getNewCases() == null) {
report.setNewCases(0);
}
if (report.getLabConfirmations() == null) {
report.setLabConfirmations(0);
}
if (report.getDeaths() == null) {
report.setDeaths(0);
}
DatabaseHelper.getAggregateReportDao().saveAndSnapshot(report);
}
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
super.onPostExecute(taskResult);
getBaseActivity().hidePreloader();
Intent intent = new Intent(getContext(), AggregateReportsActivity.class);
getContext().startActivity(intent);
if (!taskResult.getResultStatus().isSuccess()) {
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
return;
}
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_case_numbers_submitted);
}
}.executeOnThreadPool();
});
confirmationDialog.show();
}
Aggregations