Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ficat
Copy link

@Ficat Ficat commented Oct 28, 2020

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.

@Shvet
Copy link

Shvet commented Dec 17, 2021

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.

Copy link

@Shvet Shvet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried this commit in my project in which i get pdf files from server and it is working with no longer blanks showing when returning to previous tab from next tab.

odifek added a commit to techbeloved/hymnbook that referenced this pull request Sep 10, 2022
Owing to this bug DImuthuUpe/AndroidPdfViewer#956, we cannot continue with this solution yet.
odifek added a commit to techbeloved/hymnbook that referenced this pull request Sep 18, 2022
Owing to this bug DImuthuUpe/AndroidPdfViewer#956, we cannot continue with this solution yet.
Although I copied the fix and made further adjustment to stop a crash, I found that pinch zooming on music sheet doesn't work properly.
It seems that viewPager2 kind of intercepts all touches. Found a similar complaint here https://stackoverflow.com/questions/64815798/how-to-expand-the-view-while-zooming-an-image-into-viewpager2
Would test this later
@Flaviosar78
Copy link

Flaviosar78 commented Feb 21, 2023

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

@muthuraj57
Copy link

@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.

@Flaviosar78
Copy link

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?

@muthuraj57
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants