From 5e8cbb16509767f42072739b7f13391051191f89 Mon Sep 17 00:00:00 2001 From: Matt Holgate Date: Mon, 23 Jun 2014 11:06:25 +0100 Subject: Fix crash when dismissing 'Cannot open document' dialog with back button, then pressing back button again. I've also added an onCancel() handler, so that the back button only needs to be pressed once to return to the file picker view. Spotted while looking at bug #693719 - Attached PDF file does not display (edit) --- platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'platform/android') diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java index e9922a34..066b6d5f 100644 --- a/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java +++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFActivity.java @@ -9,6 +9,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.DialogInterface.OnCancelListener; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; @@ -329,6 +330,13 @@ public class MuPDFActivity extends Activity implements FilePicker.FilePickerSupp finish(); } }); + alert.setOnCancelListener(new OnCancelListener() { + + @Override + public void onCancel(DialogInterface dialog) { + finish(); + } + }); alert.show(); return; } @@ -1083,7 +1091,7 @@ public class MuPDFActivity extends Activity implements FilePicker.FilePickerSupp @Override public void onBackPressed() { - if (core.hasChanges()) { + if (core != null && core.hasChanges()) { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) -- cgit v1.2.3