Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 0c7aec5

Browse files
committed
Fix issue DImuthuUpe#315
Clean fling code Update README and CHANGELOG Update version
1 parent f0ce905 commit 0c7aec5

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.6.1 (2017-06-08)
2+
* Fix disappearing scroll handle
3+
14
## 2.6.0 (2017-06-04)
25
* Fix fling on single-page documents
36
* Greatly improve overall fling experience

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Licensed under Apache License 2.0.
1414
* Fix fling on single-page documents
1515
* Greatly improve overall fling experience
1616

17+
Version 2.6.1. fixes disappearing scroll handle
18+
1719
## Changes in 2.0 API
1820
* `Configurator#defaultPage(int)` and `PDFView#jumpTo(int)` now require page index (i.e. starting from 0)
1921
* `OnPageChangeListener#onPageChanged(int, int)` is called with page index (i.e. starting from 0)
@@ -27,7 +29,7 @@ Licensed under Apache License 2.0.
2729

2830
Add to _build.gradle_:
2931

30-
`compile 'com.github.barteksc:android-pdf-viewer:2.6.0'`
32+
`compile 'com.github.barteksc:android-pdf-viewer:2.6.1'`
3133

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

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.6.0'
16+
libraryVersion = '2.6.1'
1717

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

3838
}

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class AnimationManager {
3838

3939
private OverScroller scroller;
4040

41+
private boolean flinging = false;
42+
4143
public AnimationManager(PDFView pdfView) {
4244
this.pdfView = pdfView;
4345
scroller = new OverScroller(pdfView.getContext());
@@ -74,9 +76,21 @@ public void startZoomAnimation(float centerX, float centerY, float zoomFrom, flo
7476

7577
public void startFlingAnimation(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY) {
7678
stopAll();
79+
flinging = true;
7780
scroller.fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY);
7881
}
7982

83+
void computeFling() {
84+
if (scroller.computeScrollOffset()) {
85+
pdfView.moveTo(scroller.getCurrX(), scroller.getCurrY());
86+
pdfView.loadPageByOffset();
87+
} else if(flinging) { // fling finished
88+
flinging = false;
89+
pdfView.loadPages();
90+
hideHandle();
91+
}
92+
}
93+
8094
public void stopAll() {
8195
if (animation != null) {
8296
animation.cancel();
@@ -86,13 +100,10 @@ public void stopAll() {
86100
}
87101

88102
public void stopFling() {
103+
flinging = false;
89104
scroller.forceFinished(true);
90105
}
91106

92-
public OverScroller getScroller() {
93-
return scroller;
94-
}
95-
96107
class XAnimation implements AnimatorUpdateListener {
97108

98109
@Override

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import android.os.HandlerThread;
3232
import android.util.AttributeSet;
3333
import android.util.Log;
34-
import android.widget.OverScroller;
3534
import android.widget.RelativeLayout;
3635

3736
import com.github.barteksc.pdfviewer.listener.OnDrawListener;
@@ -528,17 +527,7 @@ public boolean isRecycled() {
528527
@Override
529528
public void computeScroll() {
530529
super.computeScroll();
531-
532-
OverScroller scroller = animationManager.getScroller();
533-
if (scroller.computeScrollOffset()) {
534-
moveTo(scroller.getCurrX(), scroller.getCurrY());
535-
loadPageByOffset();
536-
} else { // fling finished
537-
loadPages();
538-
if (getScrollHandle() != null) {
539-
getScrollHandle().hideDelayed();
540-
}
541-
}
530+
animationManager.computeFling();
542531
}
543532

544533
@Override

0 commit comments

Comments
 (0)