Skip to content

Commit 87bcd47

Browse files
committed
Fix scroll handle NPE after document loading error
Update README and CHANGELOG Update version
1 parent ce9d03a commit 87bcd47

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.3 (2016-08-30)
2+
* Fix scroll handle NPE after document loading error
3+
14
## 2.0.2 (2016-08-27)
25
* Fix exceptions caused by improperly finishing rendering task
36

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ Licensed under Apache License 2.0.
1414
* added scroll handle as a replacement for scrollbar
1515

1616
2.0.1 fixes NPE when onDetachFromWindow is called.
17+
1718
2.0.2 fixes exceptions caused by improperly finishing rendering task.
1819

20+
2.0.3 fixes scroll handle NPE after document loading error
21+
1922
## Changes in 2.0 API
2023
* `Configurator#defaultPage(int)` and `PDFView#jumpTo(int)` now require page index (i.e. starting from 0)
2124
* `OnPageChangeListener#onPageChanged(int, int)` is called with page index (i.e. starting from 0)
@@ -29,7 +32,7 @@ Licensed under Apache License 2.0.
2932

3033
Add to _build.gradle_:
3134

32-
`compile 'com.github.barteksc:android-pdf-viewer:2.0.2'`
35+
`compile 'com.github.barteksc:android-pdf-viewer:2.0.3'`
3336

3437
Library is available in jcenter repository, probably it'll be in Maven Central soon.
3538

android-pdf-viewer/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ext {
1313
siteUrl = 'https://github.com/barteksc/AndroidPdfViewer'
1414
gitUrl = 'https://github.com/barteksc/AndroidPdfViewer.git'
1515

16-
libraryVersion = '2.0.2'
16+
libraryVersion = '2.0.3'
1717

1818
developerId = 'barteksc'
1919
developerName = 'Bartosz Schiller'
@@ -32,7 +32,7 @@ android {
3232
minSdkVersion 11
3333
targetSdkVersion 23
3434
versionCode 1
35-
versionName "2.0.2"
35+
versionName "2.0.3"
3636
}
3737

3838
}

android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public void recycle() {
446446
// Clear caches
447447
cacheManager.recycle();
448448

449-
if (scrollHandle != null) {
449+
if (scrollHandle != null && state != State.ERROR) {
450450
scrollHandle.destroyLayout();
451451
}
452452

@@ -644,6 +644,7 @@ public void loadPages() {
644644
* Called when the PDF is loaded
645645
*/
646646
public void loadComplete(PdfDocument pdfDocument) {
647+
state = State.LOADED;
647648
this.documentPageCount = pdfiumCore.getPageCount(pdfDocument);
648649

649650
int firstPageIdx = 0;
@@ -656,7 +657,6 @@ public void loadComplete(PdfDocument pdfDocument) {
656657
pdfiumCore.openPage(pdfDocument, firstPageIdx);
657658
this.pageWidth = pdfiumCore.getPageWidth(pdfDocument, firstPageIdx);
658659
this.pageHeight = pdfiumCore.getPageHeight(pdfDocument, firstPageIdx);
659-
state = State.LOADED;
660660
calculateOptimalWidthAndHeight();
661661

662662
pagesLoader = new PagesLoader(this);
@@ -676,6 +676,7 @@ public void loadComplete(PdfDocument pdfDocument) {
676676
}
677677

678678
public void loadError(Throwable t) {
679+
state = State.ERROR;
679680
recycle();
680681
invalidate();
681682
if (this.onErrorListener != null) {
@@ -1129,7 +1130,7 @@ public Configurator fromUri(Uri uri) {
11291130
return new Configurator(uri.toString(), false);
11301131
}
11311132

1132-
private enum State {DEFAULT, LOADED, SHOWN}
1133+
private enum State {DEFAULT, LOADED, SHOWN, ERROR}
11331134

11341135
public class Configurator {
11351136

0 commit comments

Comments
 (0)