readium / kotlin-toolkit

A toolkit for ebooks, audiobooks and comics written in Kotlin
https://readium.org/kotlin-toolkit
BSD 3-Clause "New" or "Revised" License
163 stars 72 forks source link

Prevent reporting the current position while loading a locator #487

Closed mickael-menu closed 3 months ago

mickael-menu commented 3 months ago

While loading the EPUB navigator's initial locator, calling certain APIs too early, like submitPreferences(), can cause us to lose it. This happens because the currentLocator goes through various temporary positions before settling on the requested initial locator. If we invalidate the view pager while loading, the pending locator is cleared and replaced with the current state of the currentLocator.

I solved this by adding a State in the EpubNavigatorFragment to monitor the loading of pending locators. currentLocator will only update after the requested locator finishes loading.