MindevPDFViewer
MindevPDFViewer copied to clipboard
It does not support device's configuration change
It does not support of device rotation. The activity/fragment is recreated, then we can get both last page position and file path, to set to the MindevPDFViewer
when the onSaveInstanceState is not null. But there is no way to set them safely, because MindevPDFViewer
is always expecting a status listener object. And this object is only set when the file is downloaded, there is no other option:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
if (savedInstanceState != null){
pagePosition = savedInstanceState.getInt("CURRENT_PAGE")
filePath = savedInstanceState.getString("PATH").toString()
if(filePath.isNotEmpty()){
binding.pdfContainer.fileInit(filePath)
binding.pdfContainer.pdfRendererCore?.renderPage(pagePosition)
}
}else{
initUI()
}
}
private fun initUI() {
val url = "pdfurl.com"
binding.pdfContainer.initializePDFDownloader(url, statusListener)
}
This throws a kotlin.UninitializedPropertyAccessException: lateinit property statusListener has not been initialized
and accordign to current logic this can happen because the scrollListener
within fileInit method is using it
@cdmunoz Thank you so much for your good point. I'll try to improve it as soon as possible. Thank you 👍