summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-04-23 14:42:08 +0100
committerRobin Watts <robin.watts@artifex.com>2012-04-23 14:42:08 +0100
commited739dd54d75eef5d467c3f14531f749ed63a48a (patch)
treef9cd2f0a297035fb21df47287ec67f2cb49ccaab /android
parentea3cd505c7dfea7fd207e7b00674a3ff97413721 (diff)
downloadmupdf-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.
Diffstat (limited to 'android')
-rw-r--r--android/src/com/artifex/mupdf/MuPDFActivity.java10
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);