Fix reader state on changed
This commit is contained in:
@@ -22,6 +22,9 @@ abstract class BaseReaderAdapter<H : BasePageHolder<*>>(
|
|||||||
|
|
||||||
private val differ = AsyncListDiffer(this, DiffCallback())
|
private val differ = AsyncListDiffer(this, DiffCallback())
|
||||||
|
|
||||||
|
val hasItems: Boolean
|
||||||
|
get() = itemCount != 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
stateRestorationPolicy = StateRestorationPolicy.PREVENT
|
stateRestorationPolicy = StateRestorationPolicy.PREVENT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ abstract class BaseReaderFragment<B : ViewBinding> : BaseFragment<B>(), ZoomCont
|
|||||||
readerAdapter = onCreateAdapter()
|
readerAdapter = onCreateAdapter()
|
||||||
|
|
||||||
viewModel.content.observe(viewLifecycleOwner) {
|
viewModel.content.observe(viewLifecycleOwner) {
|
||||||
onPagesChanged(it.pages, restoredState ?: it.state)
|
var pendingState = restoredState ?: it.state
|
||||||
|
if (pendingState == null && readerAdapter?.hasItems != true) {
|
||||||
|
pendingState = viewModel.getCurrentState()
|
||||||
|
}
|
||||||
|
onPagesChanged(it.pages, pendingState)
|
||||||
restoredState = null
|
restoredState = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user