From ed739dd54d75eef5d467c3f14531f749ed63a48a Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 23 Apr 2012 14:42:08 +0100 Subject: Android tweak; more null checks. When building MuPDFActivity as part of a framework, the application lifecycle is slightly different. This can mean that if an attempt is made to open a corrupt file (that fails to open) createUI can be called with core == null. The fix is just to check that core is non-null. We add this check in various places to be doubly sure. --- android/src/com/artifex/mupdf/MuPDFActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'android/src') diff --git a/android/src/com/artifex/mupdf/MuPDFActivity.java b/android/src/com/artifex/mupdf/MuPDFActivity.java index e8dfc3cb..18c0f864 100644 --- a/android/src/com/artifex/mupdf/MuPDFActivity.java +++ b/android/src/com/artifex/mupdf/MuPDFActivity.java @@ -190,6 +190,8 @@ public class MuPDFActivity extends Activity } public void createUI(Bundle savedInstanceState) { + if (core == null) + return; // Now create the UI. // First create the document view making use of the ReaderView's internal // gesture recognition @@ -255,6 +257,8 @@ public class MuPDFActivity extends Activity } protected void onMoveToChild(int i) { + if (core == null) + return; mPageNumberView.setText(String.format("%d/%d", i+1, core.countPages())); mPageSlider.setMax(core.countPages()-1); mPageSlider.setProgress(i); @@ -479,6 +483,8 @@ public class MuPDFActivity extends Activity } void showButtons() { + if (core == null) + return; if (!mButtonsVisible) { mButtonsVisible = true; // Update page number text and slider @@ -567,6 +573,8 @@ public class MuPDFActivity extends Activity } void updatePageNumView(int index) { + if (core == null) + return; mPageNumberView.setText(String.format("%d/%d", index+1, core.countPages())); } @@ -608,6 +616,8 @@ public class MuPDFActivity extends Activity } void search(int direction) { + if (core == null) + return; killSearch(); final ProgressDialogX progressDialog = new ProgressDialogX(this); -- cgit v1.2.3