diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-04-23 14:42:08 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-23 14:42:08 +0100 |
commit | ed739dd54d75eef5d467c3f14531f749ed63a48a (patch) | |
tree | f9cd2f0a297035fb21df47287ec67f2cb49ccaab | |
parent | ea3cd505c7dfea7fd207e7b00674a3ff97413721 (diff) | |
download | mupdf-ed739dd54d75eef5d467c3f14531f749ed63a48a.tar.xz |
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.
-rw-r--r-- | android/src/com/artifex/mupdf/MuPDFActivity.java | 10 |
1 files changed, 10 insertions, 0 deletions
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); |