Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a475957

Browse files
committed
Fix bug preventing OnErrorListener from being called
1 parent 9f7c87c commit a475957

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.0.0-beta.3 (2017-11-18)
2+
* Fix bug preventing `OnErrorListener` from being called
3+
14
## 3.0.0-beta.2 (2017-11-15)
25
* Fix rendering with maximum zoom
36
* Improve fit policies

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Licensed under Apache License 2.0.
1818

1919
3.0.0-beta.2 fixes rendering with maximum zoom, improves fit policies and updates PdfiumAndroid to 1.8.1
2020

21+
3.0.0-beta.3 fixes bug preventing `OnErrorListener` from being called
22+
2123
## Changes in 3.0 API
2224
* Replaced `Contants.PRELOAD_COUNT` with `PRELOAD_OFFSET`
2325
* Removed `PDFView#fitToWidth()` (variant without arguments)
@@ -29,7 +31,7 @@ Licensed under Apache License 2.0.
2931

3032
Add to _build.gradle_:
3133

32-
`compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.2'`
34+
`compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.3'`
3335

3436
or if you want to use more stable version:
3537

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 = '3.0.0-beta.2'
16+
libraryVersion = '3.0.0-beta.3'
1717

1818
developerId = 'barteksc'
1919
developerName = 'Bartosz Schiller'
@@ -32,7 +32,7 @@ android {
3232
minSdkVersion 11
3333
targetSdkVersion 25
3434
versionCode 1
35-
versionName "3.0.0-beta.2"
35+
versionName "3.0.0-beta.3"
3636
}
3737

3838
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,13 @@ void loadComplete(PdfFile pdfFile) {
692692

693693
void loadError(Throwable t) {
694694
state = State.ERROR;
695+
// store reference, because callbacks will be cleared in recycle() method
696+
OnErrorListener onErrorListener = callbacks.getOnError();
695697
recycle();
696698
invalidate();
697-
if (!callbacks.callOnError(t)) {
699+
if (onErrorListener != null) {
700+
onErrorListener.onError(t);
701+
} else {
698702
Log.e("PDFView", "load pdf error", t);
699703
}
700704
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ public void setOnError(OnErrorListener onErrorListener) {
8383
this.onErrorListener = onErrorListener;
8484
}
8585

86-
public boolean callOnError(Throwable error) {
87-
if (onErrorListener != null) {
88-
onErrorListener.onError(error);
89-
return true;
90-
}
91-
return false;
86+
public OnErrorListener getOnError() {
87+
return onErrorListener;
9288
}
9389

9490
public void setOnPageError(OnPageErrorListener onPageErrorListener) {

0 commit comments

Comments
 (0)