Instantly show check on tab for tracked manga
This commit is contained in:
parent
2b1752de09
commit
343fad39b6
1 changed files with 12 additions and 0 deletions
|
@ -144,10 +144,22 @@ class MangaController : RxController, TabbedController {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (type.isEnter) {
|
if (type.isEnter) {
|
||||||
tabLayout()?.setupWithViewPager(manga_pager)
|
tabLayout()?.setupWithViewPager(manga_pager)
|
||||||
|
checkInitialTrackState()
|
||||||
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
|
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkInitialTrackState() {
|
||||||
|
val manga = manga ?: return
|
||||||
|
val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
||||||
|
val db = Injekt.get<DatabaseHelper>()
|
||||||
|
val tracks = db.getTracks(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
if (loggedServices.any { service -> tracks.any { it.sync_id == service.id } }) {
|
||||||
|
setTrackingIcon(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun tabLayout():TabLayout? {
|
fun tabLayout():TabLayout? {
|
||||||
return if (activity is SearchActivity) activity?.sTabs
|
return if (activity is SearchActivity) activity?.sTabs
|
||||||
else activity?.tabs
|
else activity?.tabs
|
||||||
|
|
Reference in a new issue