MindevPDFViewer icon indicating copy to clipboard operation
MindevPDFViewer copied to clipboard

It does not support device's configuration change

Open cdmunoz opened this issue 3 years ago • 1 comments

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 avatar Jul 10 '20 22:07 cdmunoz

@cdmunoz Thank you so much for your good point. I'll try to improve it as soon as possible. Thank you 👍

mkw8263 avatar Jul 11 '20 17:07 mkw8263