From 7d3f99d586d4b13b4716e1a43d11874fe562c932 Mon Sep 17 00:00:00 2001 From: Aleksandar Bozic Date: Mon, 23 May 2016 13:38:32 +0200 Subject: [PATCH] Merged PR https://github.com/JoanZapata/android-pdfview/pull/134 --- .../com/joanzapata/pdfview/DecodingAsyncTask.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/android-pdfview/src/main/java/com/joanzapata/pdfview/DecodingAsyncTask.java b/android-pdfview/src/main/java/com/joanzapata/pdfview/DecodingAsyncTask.java index 70b87da..b3beb2b 100644 --- a/android-pdfview/src/main/java/com/joanzapata/pdfview/DecodingAsyncTask.java +++ b/android-pdfview/src/main/java/com/joanzapata/pdfview/DecodingAsyncTask.java @@ -47,9 +47,14 @@ public DecodingAsyncTask(Uri uri, PDFView pdfView) { @Override protected Void doInBackground(Void... params) { - decodeService = new DecodeServiceBase(new PdfContext()); - decodeService.setContentResolver(pdfView.getContext().getContentResolver()); - decodeService.open(uri); + try { + decodeService = new DecodeServiceBase(new PdfContext()); + decodeService.setContentResolver(pdfView.getContext().getContentResolver()); + decodeService.open(uri); + } catch (Exception e){ + // Prevent java.lang.RuntimeException: PDF file is corrupted + this.cancelled = true; + } return null; }