diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt index 58856bd3f5..a2b38e4f8f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsAdapter.kt @@ -22,6 +22,7 @@ class MangaDetailsAdapter( var items: List = 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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 18a0a1388f..f8e790c4b0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -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) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index ab219955e8..8a650ebf7e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -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(