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