@@ -250,6 +250,11 @@ public class PDFView extends SurfaceView {
250250 */
251251 private boolean swipeVertical = false ;
252252
253+ /**
254+ * True if should show a page with animation
255+ */
256+ private boolean showPageWithAnimation = true ;
257+
253258 /**
254259 * Pdfium core for loading and rendering PDFs
255260 */
@@ -282,7 +287,7 @@ public class PDFView extends SurfaceView {
282287 public PDFView (Context context , AttributeSet set ) {
283288 super (context , set );
284289
285- if (isInEditMode ()) {
290+ if (isInEditMode ()) {
286291 return ;
287292 }
288293
@@ -347,7 +352,7 @@ public void jumpTo(int page) {
347352 }
348353
349354 void showPage (int pageNb ) {
350- if (recycled ) {
355+ if (recycled ) {
351356 return ;
352357 }
353358 state = State .SHOWN ;
@@ -366,11 +371,20 @@ void showPage(int pageNb) {
366371
367372 // Reset the zoom and center the page on the screen
368373 resetZoom ();
369- if (swipeVertical ) {
370- animationManager .startYAnimation (currentYOffset , calculateCenterOffsetForPage (pageNb ));
374+ if (showPageWithAnimation ) {
375+ if (swipeVertical ) {
376+ animationManager .startYAnimation (currentYOffset , calculateCenterOffsetForPage (pageNb ));
377+ } else {
378+ animationManager .startXAnimation (currentXOffset , calculateCenterOffsetForPage (pageNb ));
379+ }
371380 } else {
372- animationManager .startXAnimation (currentXOffset , calculateCenterOffsetForPage (pageNb ));
381+ if (swipeVertical ) {
382+ moveTo (getCurrentXOffset (), calculateCenterOffsetForPage (pageNb ));
383+ } else {
384+ moveTo (calculateCenterOffsetForPage (pageNb ), getCurrentYOffset ());
385+ }
373386 }
387+
374388 loadPages ();
375389
376390 if (scrollBar != null ) {
@@ -447,7 +461,7 @@ protected void onDetachedFromWindow() {
447461
448462 @ Override
449463 protected void onSizeChanged (int w , int h , int oldw , int oldh ) {
450- if (isInEditMode ()) {
464+ if (isInEditMode ()) {
451465 return ;
452466 }
453467 animationManager .stopAll ();
@@ -496,7 +510,7 @@ protected void onDraw(Canvas canvas) {
496510 // Draws background
497511 canvas .drawColor (Color .WHITE );
498512
499- if (recycled ) {
513+ if (recycled ) {
500514 return ;
501515 }
502516
@@ -641,7 +655,7 @@ public void loadPages() {
641655
642656 /**
643657 * Render a page, creating 1 to <i>nbOfPartsLoadable</i> page parts. <br><br>
644- * <p/ >
658+ * <p>
645659 * This is one of the trickiest method of this library. It finds
646660 * the DocumentPage associated with the given UserPage, loads its
647661 * thumbnail, cut this page into 256x256 blocs considering the
@@ -792,7 +806,7 @@ public void loadComplete(PdfDocument pdfDocument) {
792806 this .documentPageCount = pdfiumCore .getPageCount (pdfDocument );
793807
794808 int firstPageIdx = 0 ;
795- if (originalUserPages != null ) {
809+ if (originalUserPages != null ) {
796810 firstPageIdx = originalUserPages [0 ];
797811 }
798812
@@ -1185,14 +1199,14 @@ public void enableAnnotationRendering(boolean annotationRendering) {
11851199 }
11861200
11871201 public PdfDocument .Meta getDocumentMeta () {
1188- if (pdfDocument == null ) {
1202+ if (pdfDocument == null ) {
11891203 return null ;
11901204 }
11911205 return pdfiumCore .getDocumentMeta (pdfDocument );
11921206 }
11931207
11941208 public List <PdfDocument .Bookmark > getTableOfContents () {
1195- if (pdfDocument == null ) {
1209+ if (pdfDocument == null ) {
11961210 return new ArrayList <>();
11971211 }
11981212 return pdfiumCore .getTableOfContents (pdfDocument );
@@ -1264,6 +1278,8 @@ public class Configurator {
12641278
12651279 private boolean swipeVertical = false ;
12661280
1281+ private boolean showPageWithAnimation = true ;
1282+
12671283 private boolean annotationRendering = false ;
12681284
12691285 private int maskColor = Color .BLACK ;
@@ -1327,6 +1343,11 @@ public Configurator swipeVertical(boolean swipeVertical) {
13271343 return this ;
13281344 }
13291345
1346+ public Configurator showPageWithAnimation (boolean showPageWithAnimation ) {
1347+ this .showPageWithAnimation = showPageWithAnimation ;
1348+ return this ;
1349+ }
1350+
13301351 public Configurator password (String password ) {
13311352 this .password = password ;
13321353 return this ;
@@ -1352,6 +1373,7 @@ public void load() {
13521373 PDFView .this .setDefaultPage (defaultPage );
13531374 PDFView .this .setUserWantsMinimap (showMinimap );
13541375 PDFView .this .setSwipeVertical (swipeVertical );
1376+ PDFView .this .setShowPageWithAnimation (showPageWithAnimation );
13551377 PDFView .this .enableAnnotationRendering (annotationRendering );
13561378 PDFView .this .dragPinchManager .setSwipeVertical (swipeVertical );
13571379 PDFView .this .maskPaint = new Paint ();
@@ -1377,4 +1399,8 @@ public boolean isSwipeVertical() {
13771399 public void setSwipeVertical (boolean swipeVertical ) {
13781400 this .swipeVertical = swipeVertical ;
13791401 }
1402+
1403+ public void setShowPageWithAnimation (boolean showPageWithAnimation ) {
1404+ this .showPageWithAnimation = showPageWithAnimation ;
1405+ }
13801406}
0 commit comments