mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Use runblocking when returning from reader to details
Used so the chapter items and start reading are correct for the transition
This commit is contained in:
parent
336c567c3c
commit
44346048cb
3 changed files with 22 additions and 1 deletions
|
@ -110,6 +110,7 @@ import eu.kanade.tachiyomi.util.view.snack
|
|||
import eu.kanade.tachiyomi.util.view.toolbarHeight
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.widget.LinearLayoutManagerAccurateOffset
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -193,6 +194,7 @@ class MangaDetailsController :
|
|||
|
||||
private var headerHeight = 0
|
||||
private var fullCoverActive = false
|
||||
var returningFromReader = false
|
||||
|
||||
override fun getTitle(): String? {
|
||||
return manga?.title
|
||||
|
@ -571,6 +573,18 @@ class MangaDetailsController :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
if (!returningFromReader) return
|
||||
returningFromReader = false
|
||||
runBlocking {
|
||||
val chapters = presenter.getChaptersNow()
|
||||
tabletAdapter?.notifyItemChanged(0)
|
||||
adapter?.setChapters(chapters)
|
||||
addMangaHeader()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
|
@ -930,7 +944,6 @@ class MangaDetailsController :
|
|||
}
|
||||
|
||||
private fun openChapter(chapter: Chapter, sharedElement: View? = null) {
|
||||
MainActivity.chapterIdToExitTo = 0L
|
||||
(activity as? AppCompatActivity)?.apply {
|
||||
if (sharedElement != null) {
|
||||
val (intent, bundle) = ReaderActivity
|
||||
|
@ -942,6 +955,7 @@ class MangaDetailsController :
|
|||
(adapter?.getItem(it) as? ChapterItem)?.chapter?.id
|
||||
}.toLongArray()
|
||||
} else longArrayOf()
|
||||
returningFromReader = true
|
||||
intent.putExtra(ReaderActivity.VISIBLE_CHAPTERS, chapterRange)
|
||||
startActivity(intent, bundle)
|
||||
} else {
|
||||
|
|
|
@ -151,6 +151,11 @@ class MangaDetailsPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun getChaptersNow(): List<ChapterItem> {
|
||||
getChapters()
|
||||
return chapters
|
||||
}
|
||||
|
||||
private suspend fun getChapters() {
|
||||
val chapters = db.getChapters(manga).executeOnIO().map { it.toModel() }
|
||||
|
||||
|
|
|
@ -210,6 +210,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
const val VISIBLE_CHAPTERS = "${BuildConfig.APPLICATION_ID}.VISIBLE_CHAPTERS"
|
||||
|
||||
fun newIntent(context: Context, manga: Manga, chapter: Chapter): Intent {
|
||||
MainActivity.chapterIdToExitTo = 0L
|
||||
val intent = Intent(context, ReaderActivity::class.java)
|
||||
intent.putExtra("manga", manga.id)
|
||||
intent.putExtra("chapter", chapter.id)
|
||||
|
@ -218,6 +219,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
}
|
||||
|
||||
fun newIntentWithTransitionOptions(activity: Activity, manga: Manga, chapter: Chapter, sharedElement: View): Pair<Intent, Bundle?> {
|
||||
MainActivity.chapterIdToExitTo = 0L
|
||||
val intent = newIntent(activity, manga, chapter)
|
||||
intent.putExtra(TRANSITION_NAME, sharedElement.transitionName)
|
||||
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue