AndroidPdfViewer icon indicating copy to clipboard operation
AndroidPdfViewer copied to clipboard

fix the bug(issue: #944) blank screen issue with viewpager2

Open Ficat opened this issue 5 years ago • 5 comments

If PDFView is used in ViewPager,it may show blank page, this issue is caused by the follow code:

@Override protected void onDetachedFromWindow() { recycle(); if (renderingHandlerThread != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { renderingHandlerThread.quitSafely(); } else { renderingHandlerThread.quit(); } renderingHandlerThread = null; } super.onDetachedFromWindow(); }

I have added an option autoReleasingWhenDetachedFromWindow that developer can make a decision whether PDFView would recycle automatically when it is detached from window.

If PDFView is used in ViewPager, we can set autoReleasingWhenDetachedFromWindow = false and call PDFView#release() when fragment or parent view is destroyed to avoid this issue.

Ficat avatar Oct 28 '20 07:10 Ficat

Can this update be released? or can you provide code where to edit? i have this issue so i need to fix it on local repo.

Shvet avatar Dec 17 '21 06:12 Shvet

Good Morning, i'm facing the issue here exposed: i'm using version 2.8.2 and i don't find the option autoReleasingWhenDetachedFromWindow mentioned above.

I've also tried to implement latest beta version but it seems the option is not present in this version also.

Can you please tell me if any solution has been found to this problem?

Thank you for your work

Flaviosar78 avatar Feb 21 '23 10:02 Flaviosar78

@Flaviosar78 This issue was fixed in this fork https://github.com/TalbotGooday/AndroidPdfViewer I have a fork of this fork that I publish in maven central https://github.com/muthuraj57/AndroidPdfViewer . You can use either of these, and both have fix for this issue.

muthuraj57 avatar Feb 21 '23 19:02 muthuraj57

Just another question: i'm

@Flaviosar78 This issue was fixed in this fork https://github.com/TalbotGooday/AndroidPdfViewer I have a fork of this fork that I publish in maven central https://github.com/muthuraj57/AndroidPdfViewer . You can use either of these, and both have fix for this issue.

Thank you sir, I've implemented your fork and i'm having same behaviour: There is any option to set to avoid blank screen?

Flaviosar78 avatar Feb 22 '23 07:02 Flaviosar78

@Flaviosar78 sorry, I fixed this particular issue on the app side instead of inside the library. I wrapped the PDFView inside my own custom view , and in onAttachedToWindow callback, I just loaded the pdf file again. This fixed the issue for me.

muthuraj57 avatar Feb 22 '23 07:02 muthuraj57