mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor(WebtoonPageHolder): Remove unnecessary functions
This commit is contained in:
parent
4789a1652a
commit
28a8a675ad
1 changed files with 7 additions and 30 deletions
|
@ -98,7 +98,8 @@ class WebtoonPageHolder(
|
||||||
*/
|
*/
|
||||||
fun bind(page: ReaderPage) {
|
fun bind(page: ReaderPage) {
|
||||||
this.page = page
|
this.page = page
|
||||||
launchLoadJob()
|
loadJob?.cancel()
|
||||||
|
loadJob = scope.launch { loadPageAndProcessStatus() }
|
||||||
refreshLayoutParams()
|
refreshLayoutParams()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,24 +119,14 @@ class WebtoonPageHolder(
|
||||||
* Called when the view is recycled and added to the view pool.
|
* Called when the view is recycled and added to the view pool.
|
||||||
*/
|
*/
|
||||||
override fun recycle() {
|
override fun recycle() {
|
||||||
cancelLoadJob()
|
loadJob?.cancel()
|
||||||
cancelProgressJob()
|
progressJob?.cancel()
|
||||||
|
|
||||||
removeErrorLayout()
|
removeErrorLayout()
|
||||||
frame.recycle()
|
frame.recycle()
|
||||||
progressIndicator.setProgress(0)
|
progressIndicator.setProgress(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Observes the status of the page and notify the changes.
|
|
||||||
*
|
|
||||||
* @see processStatus
|
|
||||||
*/
|
|
||||||
private fun launchLoadJob() {
|
|
||||||
cancelLoadJob()
|
|
||||||
loadJob = scope.launch { loadPageAndProcessStatus() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun loadPageAndProcessStatus() {
|
private suspend fun loadPageAndProcessStatus() {
|
||||||
val page = page ?: return
|
val page = page ?: return
|
||||||
val loader = page.chapter.pageLoader ?: return
|
val loader = page.chapter.pageLoader ?: return
|
||||||
|
@ -149,7 +140,7 @@ class WebtoonPageHolder(
|
||||||
* Observes the progress of the page and updates view.
|
* Observes the progress of the page and updates view.
|
||||||
*/
|
*/
|
||||||
private fun launchProgressJob() {
|
private fun launchProgressJob() {
|
||||||
cancelProgressJob()
|
progressJob?.cancel()
|
||||||
|
|
||||||
val page = page ?: return
|
val page = page ?: return
|
||||||
progressJob = scope.launch {
|
progressJob = scope.launch {
|
||||||
|
@ -172,29 +163,15 @@ class WebtoonPageHolder(
|
||||||
}
|
}
|
||||||
Page.State.READY -> {
|
Page.State.READY -> {
|
||||||
setImage()
|
setImage()
|
||||||
cancelProgressJob()
|
progressJob?.cancel()
|
||||||
}
|
}
|
||||||
Page.State.ERROR -> {
|
Page.State.ERROR -> {
|
||||||
setError()
|
setError()
|
||||||
cancelProgressJob()
|
progressJob?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels loading the page and processing changes to the page's status.
|
|
||||||
*/
|
|
||||||
private fun cancelLoadJob() {
|
|
||||||
loadJob?.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsubscribes from the progress subscription.
|
|
||||||
*/
|
|
||||||
private fun cancelProgressJob() {
|
|
||||||
progressJob?.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the page is queued.
|
* Called when the page is queued.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue