Open elviss116 opened 3 years ago
Hi!
it seems you have a RecyclerView with Pdf documents on each row. This can potentially lead to memory issues, as some Pdf documents are quite heavy to load in memory. If you load/unload them as the user scrolls, you may get OutOfMemory exceptions.
Anyway, it seems the PdfRenderer
original component is failing to open one of your Pdfs.
when i load one by one , the pdf open perfect. one way to prevent the app crashing is add a try catch in PDFPageAdapter
try { PdfRenderer.Page page = getPDFPage(renderer, position); Bitmap bitmap = bitmapContainer.get(position); ssiv.setImage(ImageSource.bitmap(bitmap));
ssiv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pageClickListener.onClick(v);
}
});
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
page.close();
container.addView(v, 0);
}catch (Exception e){
System.out.println("### ERROR ### ");
}
``
hi, i have problem when load some pdfs
i have recyclerview with multiple viewtypes, when i have 5 pdf view, the app crashed
java.lang.IllegalStateException: cannot load page at android.graphics.pdf.PdfRenderer.nativeOpenPageAndGetSize(Native Method) at android.graphics.pdf.PdfRenderer.access$300(PdfRenderer.java:105) at android.graphics.pdf.PdfRenderer$Page.(PdfRenderer.java:312)
at android.graphics.pdf.PdfRenderer$Page.(PdfRenderer.java:289)
at android.graphics.pdf.PdfRenderer.openPage(PdfRenderer.java:230)
at es.voghdev.pdfviewpager.library.adapter.BasePDFPagerAdapter.getPDFPage(BasePDFPagerAdapter.java:162)
at es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter.instantiateItem(PDFPagerAdapter.java:56)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1224)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager$3.run(ViewPager.java:273)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1031)
at android.view.Choreographer.doCallbacks(Choreographer.java:854)
at android.view.Choreographer.doFrame(Choreographer.java:785)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1016)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
this is my android code
class ReleasePdfViewHolder(binding: ItemPublishReleasePdfBinding) : BaseViewHolder(binding), DownloadFile.Listener {
}