Fix crashes
This commit is contained in:
@@ -107,13 +107,14 @@ abstract class CoroutineIntentService : BaseService() {
|
||||
synchronized(this) {
|
||||
if (cancelReceiver == null && !isStopped) {
|
||||
val job = coroutineContext[Job] ?: return
|
||||
cancelReceiver = CancelReceiver(job).also { receiver ->
|
||||
CancelReceiver(job).let { receiver ->
|
||||
ContextCompat.registerReceiver(
|
||||
applicationContext,
|
||||
receiver,
|
||||
createIntentFilter(this@CoroutineIntentService, startId),
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||
)
|
||||
cancelReceiver = receiver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ abstract class LifecycleAwareViewHolder(
|
||||
private var isCurrent = false
|
||||
|
||||
init {
|
||||
parentLifecycleOwner.lifecycle.addObserver(ParentLifecycleObserver())
|
||||
itemView.post {
|
||||
parentLifecycleOwner.lifecycle.addObserver(ParentLifecycleObserver())
|
||||
}
|
||||
}
|
||||
|
||||
fun setIsCurrent(value: Boolean) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import kotlinx.coroutines.sync.withLock
|
||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||
import org.koitharu.kotatsu.details.data.MangaDetails
|
||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||
import org.koitharu.kotatsu.reader.ui.pager.ReaderPage
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -71,8 +72,8 @@ class ChaptersLoader @Inject constructor(
|
||||
return chapterId in chapterPages
|
||||
}
|
||||
|
||||
fun getPages(chapterId: Long): List<ReaderPage> {
|
||||
return chapterPages.subList(chapterId)
|
||||
fun getPages(chapterId: Long): List<MangaPage> = synchronized(chapterPages) {
|
||||
return chapterPages.subList(chapterId).map { it.toMangaPage() }
|
||||
}
|
||||
|
||||
fun getPagesCount(chapterId: Long): Int {
|
||||
|
||||
@@ -247,7 +247,7 @@ class ReaderViewModel @Inject constructor(
|
||||
|
||||
fun getCurrentChapterPages(): List<MangaPage>? {
|
||||
val chapterId = readingState.value?.chapterId ?: return null
|
||||
return chaptersLoader.getPages(chapterId).map { it.toMangaPage() }
|
||||
return chaptersLoader.getPages(chapterId)
|
||||
}
|
||||
|
||||
fun saveCurrentPage(
|
||||
|
||||
Reference in New Issue
Block a user