mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-23 13:11:14 +01:00
Fixed sorting chapters not updating properly
This commit is contained in:
parent
e43be48074
commit
362a088367
@ -22,6 +22,7 @@ class MangaDetailsAdapter(
|
||||
|
||||
var items: List<ChapterItem> = emptyList()
|
||||
|
||||
private var isAnimating = false
|
||||
val delegate: MangaDetailsInterface = controller
|
||||
|
||||
val readColor = context.getResourceColor(android.R.attr.textColorHint)
|
||||
@ -42,18 +43,24 @@ class MangaDetailsAdapter(
|
||||
return items.indexOf(item)
|
||||
}
|
||||
|
||||
fun indexOf(chapterId: Long): Int {
|
||||
return currentItems.indexOfFirst { it is ChapterItem && it.id == chapterId }
|
||||
}
|
||||
|
||||
fun performFilter() {
|
||||
val s = getFilter(String::class.java)
|
||||
if (s.isNullOrBlank()) {
|
||||
updateDataSet(items, itemCount != 0)
|
||||
updateDataSet(items, isAnimating)
|
||||
} else {
|
||||
updateDataSet(items.filter { it.name.contains(s, true) ||
|
||||
it.scanlator?.contains(s, true) == true }, itemCount != 0)
|
||||
it.scanlator?.contains(s, true) == true }, isAnimating)
|
||||
}
|
||||
isAnimating = false
|
||||
}
|
||||
|
||||
override fun onItemSwiped(position: Int, direction: Int) {
|
||||
super.onItemSwiped(position, direction)
|
||||
isAnimating = true
|
||||
when (direction) {
|
||||
ItemTouchHelper.RIGHT -> controller.bookmarkChapter(position)
|
||||
ItemTouchHelper.LEFT -> controller.toggleReadChapter(position)
|
||||
|
@ -29,6 +29,7 @@ import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.system.executeOnIO
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@ -105,9 +106,7 @@ class MangaDetailsPresenter(
|
||||
}
|
||||
|
||||
private suspend fun getChapters() {
|
||||
val chapters = withContext(Dispatchers.IO) {
|
||||
db.getChapters(manga).executeAsBlocking().map { it.toModel() }
|
||||
}
|
||||
val chapters = db.getChapters(manga).executeOnIO().map { it.toModel() }
|
||||
|
||||
// Find downloaded chapters
|
||||
setDownloadedChapters(chapters)
|
||||
@ -472,9 +471,7 @@ class MangaDetailsPresenter(
|
||||
|
||||
private fun asyncUpdateMangaAndChapters(justChapters: Boolean = false) {
|
||||
scope.launch {
|
||||
if (!justChapters) withContext(Dispatchers.IO) {
|
||||
db.updateFlags(manga).executeAsBlocking()
|
||||
}
|
||||
if (!justChapters) db.updateFlags(manga).executeOnIO()
|
||||
updateChapters()
|
||||
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
|
||||
}
|
||||
|
@ -77,19 +77,20 @@ class ChapterHolder(
|
||||
statuses.add(chapter.scanlator!!)
|
||||
}
|
||||
|
||||
read.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
read.context, if (item.read) R.drawable.eye_off
|
||||
else R.drawable.eye
|
||||
if (front_view.translationX == 0f) {
|
||||
read.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
read.context, if (item.read) R.drawable.eye_off
|
||||
else R.drawable.eye
|
||||
)
|
||||
)
|
||||
)
|
||||
bookmark.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
read.context, if (item.bookmark) R.drawable.star_off
|
||||
else R.drawable.star
|
||||
bookmark.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
read.context, if (item.bookmark) R.drawable.star_off
|
||||
else R.drawable.star
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
chapter_scanlator.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor)
|
||||
chapter_scanlator.text = statuses.joinToString(" • ")
|
||||
notifyStatus(
|
||||
|
Loading…
x
Reference in New Issue
Block a user