danjdt / android-pdfviewer

A Android PDF Viewer that render pdf using PdfRenderer and displays it in a RecyclerView.
MIT License
154 stars 31 forks source link

AsyncTask is deprecated, any plans to move to Coroutines? #7

Closed soulgen closed 1 year ago

Sash0k commented 3 years ago

I tried switching to coroutines in #10, but reverting it back (if you interesting, see commit history for details).

Problem, that we can’t ever have two pages open at the same time. If we simply offload the rendering work to a thread pool (e.g. Dispatchers.IO), we run the risk of trying to open a page in one thread while a different thread is still rendering another one, causing java.lang.IllegalStateException: Current page not closed, as explained in that arcticle.

Android 12 still have AsyncTask support, so i decided to continue using autor's implementation

soulgen commented 3 years ago

You could use Executors.newSingleThreadExecutor().asCoroutineDispatcher() to avoid IllegalStateException

Sash0k commented 1 year ago

в 2022 старый добрый асинктаск всё ещё в строю (посмотрел в тирамису - работает)

затаскивать корутины ради корутин - только раздувать приложение если будет время, запилю нормальный ридер на базе этой либы