Fix toolbar title alpha (#5910)
(cherry picked from commit cfd1b4a6c6ae55118a985ec5cb1f7858cc3a3e87) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt
This commit is contained in:
parent
4ac2873a57
commit
6af5f085cf
@ -225,6 +225,16 @@ class MangaController :
|
|||||||
|
|
||||||
private var dialog: MangaFullCoverDialog? = null
|
private var dialog: MangaFullCoverDialog? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For [recyclerViewUpdatesToolbarTitleAlpha]
|
||||||
|
*/
|
||||||
|
private var recyclerViewToolbarTitleAlphaUpdaterAdded = false
|
||||||
|
private val recyclerViewToolbarTitleAlphaUpdater = object : RecyclerView.OnScrollListener() {
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
updateToolbarTitleAlpha()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
val smartSearchConfig: SourceController.SmartSearchConfig? = args.getParcelable(
|
val smartSearchConfig: SourceController.SmartSearchConfig? = args.getParcelable(
|
||||||
SMART_SEARCH_CONFIG_EXTRA
|
SMART_SEARCH_CONFIG_EXTRA
|
||||||
@ -245,15 +255,12 @@ class MangaController :
|
|||||||
|
|
||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
|
|
||||||
// Hide toolbar title on enter
|
// Hide toolbar title on enter
|
||||||
if (type.isEnter) {
|
// No need to update alpha for cover dialog
|
||||||
updateToolbarTitleAlpha()
|
if (dialog == null) {
|
||||||
} else if (!type.isPush) {
|
updateToolbarTitleAlpha(if (type.isEnter) 0F else 1F)
|
||||||
// Cancel listeners early
|
|
||||||
viewScope.cancel()
|
|
||||||
updateToolbarTitleAlpha(1F)
|
|
||||||
}
|
}
|
||||||
|
recyclerViewUpdatesToolbarTitleAlpha(type.isEnter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeEnded(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeEnded(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
@ -316,19 +323,15 @@ class MangaController :
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
it.scrollEvents()
|
|
||||||
.onEach { updateToolbarTitleAlpha() }
|
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
// Skips directly to chapters list if navigated to from the library
|
// Skips directly to chapters list if navigated to from the library
|
||||||
it.post {
|
it.post {
|
||||||
if (!fromSource && preferences.jumpToChapters()) {
|
if (!fromSource && preferences.jumpToChapters()) {
|
||||||
(it.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(1, 0)
|
val mainActivityAppBar = (activity as? MainActivity)?.binding?.appbar
|
||||||
}
|
(it.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||||
|
1,
|
||||||
// Delayed in case we need to jump to chapters
|
mainActivityAppBar?.height ?: 0
|
||||||
it.post {
|
)
|
||||||
updateToolbarTitleAlpha()
|
mainActivityAppBar?.isLifted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,27 +368,15 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tablet layout
|
// Tablet layout
|
||||||
binding.infoRecycler?.let {
|
binding.infoRecycler?.adapter = ConcatAdapter(
|
||||||
it.adapter = ConcatAdapter(
|
listOfNotNull(
|
||||||
listOfNotNull(
|
mangaInfoAdapter,
|
||||||
mangaInfoAdapter,
|
mangaInfoButtonsAdapter
|
||||||
mangaInfoButtonsAdapter
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
it.scrollEvents()
|
binding.chaptersRecycler?.adapter = ConcatAdapter(chaptersHeaderAdapter, chaptersAdapter)
|
||||||
.onEach { updateToolbarTitleAlpha() }
|
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
// Delayed in case we need to jump to chapters
|
|
||||||
it.post {
|
|
||||||
updateToolbarTitleAlpha()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.chaptersRecycler?.let {
|
|
||||||
it.adapter = ConcatAdapter(chaptersHeaderAdapter, chaptersAdapter)
|
|
||||||
}
|
|
||||||
|
|
||||||
chaptersAdapter?.fastScroller = binding.fastScroller
|
chaptersAdapter?.fastScroller = binding.fastScroller
|
||||||
|
|
||||||
@ -418,6 +409,20 @@ class MangaController :
|
|||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
updateFilterIconState()
|
updateFilterIconState()
|
||||||
|
recyclerViewUpdatesToolbarTitleAlpha(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun recyclerViewUpdatesToolbarTitleAlpha(enable: Boolean) {
|
||||||
|
val recycler = binding.fullRecycler ?: binding.infoRecycler ?: return
|
||||||
|
if (enable) {
|
||||||
|
if (!recyclerViewToolbarTitleAlphaUpdaterAdded) {
|
||||||
|
recycler.addOnScrollListener(recyclerViewToolbarTitleAlphaUpdater)
|
||||||
|
recyclerViewToolbarTitleAlphaUpdaterAdded = true
|
||||||
|
}
|
||||||
|
} else if (recyclerViewToolbarTitleAlphaUpdaterAdded) {
|
||||||
|
recycler.removeOnScrollListener(recyclerViewToolbarTitleAlphaUpdater)
|
||||||
|
recyclerViewToolbarTitleAlphaUpdaterAdded = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateToolbarTitleAlpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float? = null) {
|
private fun updateToolbarTitleAlpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float? = null) {
|
||||||
@ -478,6 +483,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
|
recyclerViewUpdatesToolbarTitleAlpha(false)
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
binding.actionToolbar.destroy()
|
binding.actionToolbar.destroy()
|
||||||
mangaInfoAdapter = null
|
mangaInfoAdapter = null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user