Fix backup job exception

pull/127/merge
Alex Baker 9 years ago
parent f46aebb784
commit a0183c5976

@ -9,6 +9,7 @@ import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.Nullable;
import android.util.Xml; import android.util.Xml;
import android.widget.Toast; import android.widget.Toast;
@ -98,7 +99,7 @@ public class TasksXmlExporter {
this.preferences = preferences; this.preferences = preferences;
} }
public void exportTasks(final Context context, final ExportType exportType, final ProgressDialog progressDialog) { public void exportTasks(final Context context, final ExportType exportType, @Nullable final ProgressDialog progressDialog) {
this.context = context; this.context = context;
this.exportCount = 0; this.exportCount = 0;
this.backupDirectory = preferences.getBackupDirectory(); this.backupDirectory = preferences.getBackupDirectory();
@ -106,9 +107,6 @@ public class TasksXmlExporter {
this.progressDialog = progressDialog; this.progressDialog = progressDialog;
handler = exportType == ExportType.EXPORT_TYPE_MANUAL ? new Handler() : null; handler = exportType == ExportType.EXPORT_TYPE_MANUAL ? new Handler() : null;
if(exportType != ExportType.EXPORT_TYPE_MANUAL) {
this.progressDialog = new ProgressDialog(context);
}
new Thread(() -> { new Thread(() -> {
try { try {
@ -129,7 +127,7 @@ public class TasksXmlExporter {
Timber.e(e, e.getMessage()); Timber.e(e, e.getMessage());
} finally { } finally {
post(() -> { post(() -> {
if(progressDialog.isShowing() && context instanceof Activity) { if(progressDialog != null && progressDialog.isShowing() && context instanceof Activity) {
DialogUtilities.dismissDialog((Activity) context, progressDialog); DialogUtilities.dismissDialog((Activity) context, progressDialog);
} }
}); });

Loading…
Cancel
Save