File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -245,8 +245,6 @@ ScrollHandle getScrollHandle() {
245
245
public PDFView (Context context , AttributeSet set ) {
246
246
super (context , set );
247
247
248
- renderingHandlerThread = new HandlerThread ("PDF renderer" );
249
-
250
248
if (isInEditMode ()) {
251
249
return ;
252
250
}
@@ -462,6 +460,14 @@ public void computeScroll() {
462
460
animationManager .computeFling ();
463
461
}
464
462
463
+ @ Override
464
+ protected void onAttachedToWindow () {
465
+ super .onAttachedToWindow ();
466
+ if (renderingHandlerThread == null ) {
467
+ renderingHandlerThread = new HandlerThread ("PDF renderer" );
468
+ }
469
+ }
470
+
465
471
@ Override
466
472
protected void onDetachedFromWindow () {
467
473
recycle ();
@@ -753,6 +759,10 @@ void loadComplete(PdfFile pdfFile) {
753
759
754
760
this .pdfFile = pdfFile ;
755
761
762
+ if (renderingHandlerThread == null ) {
763
+ return ;
764
+ }
765
+
756
766
if (!renderingHandlerThread .isAlive ()) {
757
767
renderingHandlerThread .start ();
758
768
}
You can’t perform that action at this time.
0 commit comments