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() {
245245 public PDFView (Context context , AttributeSet set ) {
246246 super (context , set );
247247
248- renderingHandlerThread = new HandlerThread ("PDF renderer" );
249-
250248 if (isInEditMode ()) {
251249 return ;
252250 }
@@ -462,6 +460,14 @@ public void computeScroll() {
462460 animationManager .computeFling ();
463461 }
464462
463+ @ Override
464+ protected void onAttachedToWindow () {
465+ super .onAttachedToWindow ();
466+ if (renderingHandlerThread == null ) {
467+ renderingHandlerThread = new HandlerThread ("PDF renderer" );
468+ }
469+ }
470+
465471 @ Override
466472 protected void onDetachedFromWindow () {
467473 recycle ();
@@ -753,6 +759,10 @@ void loadComplete(PdfFile pdfFile) {
753759
754760 this .pdfFile = pdfFile ;
755761
762+ if (renderingHandlerThread == null ) {
763+ return ;
764+ }
765+
756766 if (!renderingHandlerThread .isAlive ()) {
757767 renderingHandlerThread .start ();
758768 }
You can’t perform that action at this time.
0 commit comments