@@ -250,6 +250,11 @@ public class PDFView extends SurfaceView {
250
250
*/
251
251
private boolean swipeVertical = false ;
252
252
253
+ /**
254
+ * True if should show a page with animation
255
+ */
256
+ private boolean showPageWithAnimation = true ;
257
+
253
258
/**
254
259
* Pdfium core for loading and rendering PDFs
255
260
*/
@@ -282,7 +287,7 @@ public class PDFView extends SurfaceView {
282
287
public PDFView (Context context , AttributeSet set ) {
283
288
super (context , set );
284
289
285
- if (isInEditMode ()) {
290
+ if (isInEditMode ()) {
286
291
return ;
287
292
}
288
293
@@ -347,7 +352,7 @@ public void jumpTo(int page) {
347
352
}
348
353
349
354
void showPage (int pageNb ) {
350
- if (recycled ) {
355
+ if (recycled ) {
351
356
return ;
352
357
}
353
358
state = State .SHOWN ;
@@ -366,11 +371,20 @@ void showPage(int pageNb) {
366
371
367
372
// Reset the zoom and center the page on the screen
368
373
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
+ }
371
380
} else {
372
- animationManager .startXAnimation (currentXOffset , calculateCenterOffsetForPage (pageNb ));
381
+ if (swipeVertical ) {
382
+ moveTo (getCurrentXOffset (), calculateCenterOffsetForPage (pageNb ));
383
+ } else {
384
+ moveTo (calculateCenterOffsetForPage (pageNb ), getCurrentYOffset ());
385
+ }
373
386
}
387
+
374
388
loadPages ();
375
389
376
390
if (scrollBar != null ) {
@@ -447,7 +461,7 @@ protected void onDetachedFromWindow() {
447
461
448
462
@ Override
449
463
protected void onSizeChanged (int w , int h , int oldw , int oldh ) {
450
- if (isInEditMode ()) {
464
+ if (isInEditMode ()) {
451
465
return ;
452
466
}
453
467
animationManager .stopAll ();
@@ -496,7 +510,7 @@ protected void onDraw(Canvas canvas) {
496
510
// Draws background
497
511
canvas .drawColor (Color .WHITE );
498
512
499
- if (recycled ) {
513
+ if (recycled ) {
500
514
return ;
501
515
}
502
516
@@ -641,7 +655,7 @@ public void loadPages() {
641
655
642
656
/**
643
657
* Render a page, creating 1 to <i>nbOfPartsLoadable</i> page parts. <br><br>
644
- * <p/ >
658
+ * <p>
645
659
* This is one of the trickiest method of this library. It finds
646
660
* the DocumentPage associated with the given UserPage, loads its
647
661
* thumbnail, cut this page into 256x256 blocs considering the
@@ -792,7 +806,7 @@ public void loadComplete(PdfDocument pdfDocument) {
792
806
this .documentPageCount = pdfiumCore .getPageCount (pdfDocument );
793
807
794
808
int firstPageIdx = 0 ;
795
- if (originalUserPages != null ) {
809
+ if (originalUserPages != null ) {
796
810
firstPageIdx = originalUserPages [0 ];
797
811
}
798
812
@@ -1185,14 +1199,14 @@ public void enableAnnotationRendering(boolean annotationRendering) {
1185
1199
}
1186
1200
1187
1201
public PdfDocument .Meta getDocumentMeta () {
1188
- if (pdfDocument == null ) {
1202
+ if (pdfDocument == null ) {
1189
1203
return null ;
1190
1204
}
1191
1205
return pdfiumCore .getDocumentMeta (pdfDocument );
1192
1206
}
1193
1207
1194
1208
public List <PdfDocument .Bookmark > getTableOfContents () {
1195
- if (pdfDocument == null ) {
1209
+ if (pdfDocument == null ) {
1196
1210
return new ArrayList <>();
1197
1211
}
1198
1212
return pdfiumCore .getTableOfContents (pdfDocument );
@@ -1264,6 +1278,8 @@ public class Configurator {
1264
1278
1265
1279
private boolean swipeVertical = false ;
1266
1280
1281
+ private boolean showPageWithAnimation = true ;
1282
+
1267
1283
private boolean annotationRendering = false ;
1268
1284
1269
1285
private int maskColor = Color .BLACK ;
@@ -1327,6 +1343,11 @@ public Configurator swipeVertical(boolean swipeVertical) {
1327
1343
return this ;
1328
1344
}
1329
1345
1346
+ public Configurator showPageWithAnimation (boolean showPageWithAnimation ) {
1347
+ this .showPageWithAnimation = showPageWithAnimation ;
1348
+ return this ;
1349
+ }
1350
+
1330
1351
public Configurator password (String password ) {
1331
1352
this .password = password ;
1332
1353
return this ;
@@ -1352,6 +1373,7 @@ public void load() {
1352
1373
PDFView .this .setDefaultPage (defaultPage );
1353
1374
PDFView .this .setUserWantsMinimap (showMinimap );
1354
1375
PDFView .this .setSwipeVertical (swipeVertical );
1376
+ PDFView .this .setShowPageWithAnimation (showPageWithAnimation );
1355
1377
PDFView .this .enableAnnotationRendering (annotationRendering );
1356
1378
PDFView .this .dragPinchManager .setSwipeVertical (swipeVertical );
1357
1379
PDFView .this .maskPaint = new Paint ();
@@ -1377,4 +1399,8 @@ public boolean isSwipeVertical() {
1377
1399
public void setSwipeVertical (boolean swipeVertical ) {
1378
1400
this .swipeVertical = swipeVertical ;
1379
1401
}
1402
+
1403
+ public void setShowPageWithAnimation (boolean showPageWithAnimation ) {
1404
+ this .showPageWithAnimation = showPageWithAnimation ;
1405
+ }
1380
1406
}
0 commit comments