afreakyelf / Pdf-Viewer

A Lightweight PDF Viewer Android library which only occupies around 80kb while most of the Pdf viewer occupies up to 16MB space.
https://afreakyelf.github.io/Pdf-Viewer/
MIT License
692 stars 150 forks source link

Loading Progress #116

Closed cwaliimran closed 3 months ago

cwaliimran commented 3 months ago

Can we have more methods as we have onPdfError() There should be methods including progress onStartLoading, onLoadedSuccess so we can show and hide progressbar

github-actions[bot] commented 3 months ago

Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon. Need help or want to discuss this issue? Join our Discord community here to ask questions and discuss this issue live!

afreakyelf commented 3 months ago

Hey you can track the progress in onPdfLoadProgress by implementing status listener.

 binding.pdfView.statusListener = object : PdfRendererView.StatusCallBack {
                override fun onPdfLoadStart() {
                    Log.i("statusCallBack","onPdfLoadStart")
                }
                override fun onPdfLoadProgress(
                    progress: Int,
                    downloadedBytes: Long,
                    totalBytes: Long?
                ) {
                    //Download is in progress
                }

                override fun onPdfLoadSuccess(absolutePath: String) {
                    Log.i("statusCallBack","onPdfLoadSuccess")
                }

                override fun onError(error: Throwable) {
                    Log.i("statusCallBack","onError")
                }

                override fun onPageChanged(currentPage: Int, totalPage: Int) {
                    //Page change. Not require
                }
            }

If you need further help, feel free to join https://discord.gg/z9qQSHMxSR for faster help.

cwaliimran commented 3 months ago

It works like a charm. Thank you If anyone having issue, please consider different versions have different override methods