diff --git a/src/main/java/org/ligi/passandroid/ui/ExportProblemPassToLigiAndFinishTask.java b/src/main/java/org/ligi/passandroid/ui/ExportProblemPassToLigiAndFinishTask.java index 510498aa..f3afbd35 100644 --- a/src/main/java/org/ligi/passandroid/ui/ExportProblemPassToLigiAndFinishTask.java +++ b/src/main/java/org/ligi/passandroid/ui/ExportProblemPassToLigiAndFinishTask.java @@ -6,11 +6,8 @@ import android.net.Uri; class ExportProblemPassToLigiAndFinishTask extends PassExportTask { - private final Activity activity; - public ExportProblemPassToLigiAndFinishTask(Activity activity, String path, String zip_path, String zip_fname) { super(activity, path, zip_path, zip_fname, false); - this.activity = activity; } @Override @@ -25,7 +22,7 @@ class ExportProblemPassToLigiAndFinishTask extends PassExportTask { it.setType("text/plain"); it.putExtra(Intent.EXTRA_TEXT, ""); - ctx.startActivity(Intent.createChooser(it, "How to send Pass?")); + activity.startActivity(Intent.createChooser(it, "How to send Pass?")); activity.finish(); diff --git a/src/main/java/org/ligi/passandroid/ui/PassExportTask.java b/src/main/java/org/ligi/passandroid/ui/PassExportTask.java index 185654e2..3832c6e1 100644 --- a/src/main/java/org/ligi/passandroid/ui/PassExportTask.java +++ b/src/main/java/org/ligi/passandroid/ui/PassExportTask.java @@ -1,7 +1,7 @@ package org.ligi.passandroid.ui; +import android.app.Activity; import android.app.ProgressDialog; -import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; @@ -20,32 +20,32 @@ import java.util.zip.ZipOutputStream; class PassExportTask extends AsyncTask { private final ProgressDialog progress_dialog; - protected final Context ctx; + protected final Activity activity; private final String inputPath; protected final String zipFileName, zipPath; private boolean share_after_export; private Exception exception; - public PassExportTask(final Context ctx, + public PassExportTask(final Activity activity, final String inputPath, final String zipPath, final String zipFileName, final boolean share_after_export) { super(); - this.ctx = ctx; + this.activity = activity; this.inputPath = inputPath; this.zipFileName = zipFileName; this.zipPath = zipPath; this.share_after_export = share_after_export; - progress_dialog = new ProgressDialog(ctx); + progress_dialog = new ProgressDialog(activity); } @Override protected void onPreExecute() { - progress_dialog.setTitle(ctx.getString(R.string.preparing_pass)); - progress_dialog.setMessage(ctx.getString(R.string.please_wait)); + progress_dialog.setTitle(activity.getString(R.string.preparing_pass)); + progress_dialog.setMessage(activity.getString(R.string.please_wait)); progress_dialog.show(); super.onPreExecute(); } @@ -97,21 +97,21 @@ class PassExportTask extends AsyncTask { protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); - if (progress_dialog.isShowing()) { + if (!activity.isFinishing() && progress_dialog.isShowing()) { progress_dialog.dismiss(); } if (exception != null) { - Toast.makeText(ctx, "could not export pass " + exception, Toast.LENGTH_LONG).show(); + Toast.makeText(activity, "could not export pass " + exception, Toast.LENGTH_LONG).show(); return; } if (share_after_export) { Intent it = new Intent(Intent.ACTION_SEND); - it.putExtra(Intent.EXTRA_SUBJECT, ctx.getString(R.string.passbook_is_shared_subject)); + it.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.passbook_is_shared_subject)); it.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + zipPath + zipFileName)); it.setType("application/vnd.apple.pkpass"); - ctx.startActivity(Intent.createChooser(it, ctx.getString(R.string.passbook_share_chooser_title))); + activity.startActivity(Intent.createChooser(it, activity.getString(R.string.passbook_share_chooser_title))); } }