DImuthuUpe / AndroidPdfViewer

Android view for displaying PDFs rendered with PdfiumAndroid
Apache License 2.0
8.18k stars 1.91k forks source link

NullPointerException loading a file a second time via LifecycleObserver #994

Open yaugenka opened 3 years ago

yaugenka commented 3 years ago

I have pdfview in a fragment. The fragment calls its parent activity when it is created to download a pdf file if necessary and then the activity calls a method in the fragment to actually load the file into pdfview.

I have recently migrated to sdk30 and androidx.lifecycle 2.3 and have faced some weird behavior. If the fragment calls the activity via onActivityCreated then everything works well. Bu if it does it via the new LifecycleObserver way then pdfview crashes with NullPointerException. It's also worth noting that it starts crashing only after a file was loaded into pdfview once.

yurijdvornyk commented 3 years ago

Hi @yaugenka were you able to fix it? @barteksc , any updates on this?

yaugenka commented 3 years ago

No, I just switched back to using onActivityCreated instead of LifecycleObserver.