Re-add some stuff from EH that I lost along the way

This commit is contained in:
Jobobby04 2020-10-19 21:05:24 -04:00
parent 1dfe3890a9
commit 89d9768759
2 changed files with 23 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.elvishew.xlog.XLog
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.snackbar.Snackbar
import eu.davidea.flexibleadapter.FlexibleAdapter
@ -107,6 +108,7 @@ import kotlinx.coroutines.withContext
import reactivecircus.flowbinding.android.view.clicks
import reactivecircus.flowbinding.recyclerview.scrollEvents
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
import rx.android.schedulers.AndroidSchedulers
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@ -149,6 +151,18 @@ class MangaController :
@Suppress("unused")
constructor(bundle: Bundle) : this(bundle.getLong(MANGA_EXTRA))
// SY -->
constructor(redirect: MangaPresenter.EXHRedirect) : super(Bundle().apply {
putLong(MANGA_EXTRA, redirect.manga.id!!)
putBoolean(UPDATE_EXTRA, redirect.update)
}) {
this.manga = redirect.manga
if (manga != null) {
source = Injekt.get<SourceManager>().getOrStub(redirect.manga.source)
}
}
// SY <--
var manga: Manga? = null
private set
@ -321,6 +335,14 @@ class MangaController :
}
}
presenter.redirectUserRelay
.observeOn(AndroidSchedulers.mainThread())
.subscribeUntilDestroy { redirect ->
XLog.d("Redirecting to updated manga (manga.id: %s, manga.title: %s, update: %s)!", redirect.manga.id, redirect.manga.title, redirect.update)
// Replace self
router?.replaceTopController(MangaController(redirect).withFadeTransaction())
}
updateFilterIconState()
}

View File

@ -116,7 +116,7 @@ class MangaPresenter(
private val updateHelper: EHentaiUpdateHelper by injectLazy()
private val redirectUserRelay = BehaviorRelay.create<EXHRedirect>()
val redirectUserRelay = BehaviorRelay.create<EXHRedirect>()
data class EXHRedirect(val manga: Manga, val update: Boolean)