mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-16 13:27:28 -04:00
Fix cancelling import/export by tapping away from dialog
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -90,16 +91,20 @@ public class ImportExportTask implements CompatCallable<ImportExportResult> {
|
||||
progress = new ProgressDialog(activity);
|
||||
progress.setTitle(doImport ? R.string.importing : R.string.exporting);
|
||||
|
||||
progress.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
ImportExportTask.this.stop();
|
||||
}
|
||||
});
|
||||
progress.setOnCancelListener(dialog -> cancel(doImport, true));
|
||||
progress.setOnDismissListener(dialog -> cancel(doImport, true));
|
||||
|
||||
progress.show();
|
||||
}
|
||||
|
||||
private void cancel(boolean isImport, boolean showToast) {
|
||||
ImportExportTask.this.stop();
|
||||
|
||||
if (showToast) {
|
||||
Toast.makeText(activity, isImport ? R.string.importCancelled : R.string.exportCancelled, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
protected ImportExportResult doInBackground(Void... nothing) {
|
||||
final SQLiteDatabase database = new DBHelper(activity).getWritableDatabase();
|
||||
ImportExportResult result;
|
||||
|
||||
@@ -347,4 +347,6 @@
|
||||
<string name="multipleBarcodesFoundPleaseChooseOne">Which of the found barcodes do you want to use?</string>
|
||||
<string name="pageWithNumber">Page <xliff:g>%d</xliff:g></string>
|
||||
<string name="noCameraFoundGuideText">Your device does not seem to have a camera. If it does, try rebooting the device. Otherwise, use the "More options" button below to add a barcode another way.</string>
|
||||
<string name="importCancelled">Import cancelled</string>
|
||||
<string name="exportCancelled">Export cancelled</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user