From 8e3a65f1588eca58a627dd9f914ae0b7ae06a939 Mon Sep 17 00:00:00 2001 From: Javier Solano Date: Wed, 9 Sep 2020 10:20:08 +0200 Subject: [PATCH] Create swipe animation duration property --- .../barteksc/pdfviewer/AnimationManager.java | 16 +++++++++++++--- .../com/github/barteksc/pdfviewer/PDFView.java | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/AnimationManager.java b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/AnimationManager.java index e7e9439f..ba3f3677 100644 --- a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/AnimationManager.java +++ b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/AnimationManager.java @@ -43,6 +43,8 @@ class AnimationManager { private boolean pageFlinging = false; + private long animationDuration = 400; + public AnimationManager(PDFView pdfView) { this.pdfView = pdfView; scroller = new OverScroller(pdfView.getContext()); @@ -55,7 +57,7 @@ public void startXAnimation(float xFrom, float xTo) { animation.setInterpolator(new DecelerateInterpolator()); animation.addUpdateListener(xAnimation); animation.addListener(xAnimation); - animation.setDuration(400); + animation.setDuration(animationDuration); animation.start(); } @@ -66,7 +68,7 @@ public void startYAnimation(float yFrom, float yTo) { animation.setInterpolator(new DecelerateInterpolator()); animation.addUpdateListener(yAnimation); animation.addListener(yAnimation); - animation.setDuration(400); + animation.setDuration(animationDuration); animation.start(); } @@ -77,7 +79,7 @@ public void startZoomAnimation(float centerX, float centerY, float zoomFrom, flo ZoomAnimation zoomAnim = new ZoomAnimation(centerX, centerY); animation.addUpdateListener(zoomAnim); animation.addListener(zoomAnim); - animation.setDuration(400); + animation.setDuration(animationDuration); animation.start(); } @@ -125,6 +127,14 @@ public boolean isFlinging() { return flinging || pageFlinging; } + public void setAnimationDuration(long animationDuration) { + this.animationDuration = animationDuration; + } + + public long getAnimationDuration() { + return animationDuration; + } + class XAnimation extends AnimatorListenerAdapter implements AnimatorUpdateListener { @Override diff --git a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java index b8374721..077966d6 100644 --- a/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java +++ b/android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java @@ -1521,6 +1521,11 @@ public Configurator disableLongpress() { return this; } + public Configurator animationDuration(long duration){ + animationManager.setAnimationDuration(duration); + return this; + } + public void load() { if (!hasSize) { waitingDocumentConfigurator = this;