mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 06:21:52 +01:00
Fix not being able to scroll sometimes on extensions
This commit is contained in:
parent
474e125d59
commit
fe7c235110
@ -142,6 +142,12 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
presenter.getExtensionUpdateCount()
|
presenter.getExtensionUpdateCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updatedNestedRecyclers() {
|
||||||
|
listOf(extensionFrameLayout, migrationFrameLayout).forEachIndexed { index, recyclerWithScrollerBinding ->
|
||||||
|
recyclerWithScrollerBinding.recycler.isNestedScrollingEnabled = binding.pager.currentItem == index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun fetchOnlineExtensionsIfNeeded() {
|
fun fetchOnlineExtensionsIfNeeded() {
|
||||||
if (shouldCallApi) {
|
if (shouldCallApi) {
|
||||||
presenter.findAvailableExtensions()
|
presenter.findAvailableExtensions()
|
||||||
|
@ -140,14 +140,14 @@ class BrowseController :
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.recycler?.post {
|
binding.recycler.post {
|
||||||
setBottomSheetTabs(if (binding.bottomSheet.extBottomSheet?.sheetBehavior.isCollapsed()) 0f else 1f)
|
setBottomSheetTabs(if (binding.bottomSheet.root.sheetBehavior.isCollapsed()) 0f else 1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
||||||
binding.bottomSheet.extBottomSheet.onCreate(this)
|
binding.bottomSheet.root.onCreate(this)
|
||||||
|
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.addBottomSheetCallback(
|
binding.bottomSheet.root.sheetBehavior?.addBottomSheetCallback(
|
||||||
object : BottomSheetBehavior
|
object : BottomSheetBehavior
|
||||||
.BottomSheetCallback() {
|
.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
@ -167,7 +167,10 @@ class BrowseController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStateChanged(p0: View, state: Int) {
|
override fun onStateChanged(p0: View, state: Int) {
|
||||||
val extBottomSheet = binding.bottomSheet.extBottomSheet ?: return
|
if (state == BottomSheetBehavior.STATE_SETTLING) {
|
||||||
|
binding.bottomSheet.root.updatedNestedRecyclers()
|
||||||
|
}
|
||||||
|
val extBottomSheet = binding.bottomSheet.root
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
activityBinding?.appBar?.y = 0f
|
activityBinding?.appBar?.y = 0f
|
||||||
}
|
}
|
||||||
@ -195,7 +198,7 @@ class BrowseController :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (showingExtensions) {
|
if (showingExtensions) {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.expand()
|
binding.bottomSheet.root.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +208,7 @@ class BrowseController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setBottomSheetTabs(progress: Float) {
|
fun setBottomSheetTabs(progress: Float) {
|
||||||
val bottomSheet = binding.bottomSheet.extBottomSheet ?: return
|
val bottomSheet = binding.bottomSheet.root
|
||||||
binding.bottomSheet.tabs.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.bottomSheet.tabs.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
topMargin = ((activityBinding?.appBar?.height?.minus(9f.dpToPx) ?: 0f) * progress).toInt()
|
topMargin = ((activityBinding?.appBar?.height?.minus(9f.dpToPx) ?: 0f) * progress).toInt()
|
||||||
}
|
}
|
||||||
@ -244,42 +247,41 @@ class BrowseController :
|
|||||||
|
|
||||||
private fun setBottomPadding() {
|
private fun setBottomPadding() {
|
||||||
val bottomBar = activityBinding?.bottomNav ?: return
|
val bottomBar = activityBinding?.bottomNav ?: return
|
||||||
binding.bottomSheet.extBottomSheet ?: return
|
|
||||||
val pad = bottomBar.translationY - bottomBar.height
|
val pad = bottomBar.translationY - bottomBar.height
|
||||||
val padding = max(
|
val padding = max(
|
||||||
(-pad).toInt(),
|
(-pad).toInt(),
|
||||||
if (binding.bottomSheet.extBottomSheet.sheetBehavior.isExpanded()) 0 else {
|
if (binding.bottomSheet.root.sheetBehavior.isExpanded()) 0 else {
|
||||||
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
|
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
binding.shadow2.translationY = pad
|
binding.shadow2.translationY = pad
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.peekHeight = 58.spToPx + padding
|
binding.bottomSheet.root.sheetBehavior?.peekHeight = 58.spToPx + padding
|
||||||
binding.bottomSheet.extBottomSheet.extensionFrameLayout.fastScroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.bottomSheet.root.extensionFrameLayout.fastScroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = -pad.toInt()
|
bottomMargin = -pad.toInt()
|
||||||
}
|
}
|
||||||
binding.bottomSheet.extBottomSheet.migrationFrameLayout.fastScroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.bottomSheet.root.migrationFrameLayout.fastScroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = -pad.toInt()
|
bottomMargin = -pad.toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.expand()
|
binding.bottomSheet.root.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (!binding.bottomSheet.extBottomSheet.sheetBehavior.isCollapsed()) {
|
if (!binding.bottomSheet.root.sheetBehavior.isCollapsed()) {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.collapse()
|
binding.bottomSheet.root.sheetBehavior?.collapse()
|
||||||
} else {
|
} else {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.expand()
|
binding.bottomSheet.root.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sheetIsExpanded(): Boolean = binding.bottomSheet.extBottomSheet.sheetBehavior.isExpanded()
|
override fun sheetIsExpanded(): Boolean = binding.bottomSheet.root.sheetBehavior.isExpanded()
|
||||||
|
|
||||||
override fun handleSheetBack(): Boolean {
|
override fun handleSheetBack(): Boolean {
|
||||||
if (!binding.bottomSheet.extBottomSheet.sheetBehavior.isCollapsed()) {
|
if (!binding.bottomSheet.root.sheetBehavior.isCollapsed()) {
|
||||||
if (binding.bottomSheet.extBottomSheet.canGoBack()) {
|
if (binding.bottomSheet.root.canGoBack()) {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior?.collapse()
|
binding.bottomSheet.root.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -294,20 +296,20 @@ class BrowseController :
|
|||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (!type.isPush) {
|
if (!type.isPush) {
|
||||||
binding.bottomSheet.extBottomSheet.updateExtTitle()
|
binding.bottomSheet.root.updateExtTitle()
|
||||||
binding.bottomSheet.extBottomSheet.presenter.refreshExtensions()
|
binding.bottomSheet.root.presenter.refreshExtensions()
|
||||||
presenter.updateSources()
|
presenter.updateSources()
|
||||||
}
|
}
|
||||||
if (!type.isEnter) {
|
if (!type.isEnter) {
|
||||||
binding.bottomSheet.extBottomSheet.canExpand = false
|
binding.bottomSheet.root.canExpand = false
|
||||||
activityBinding?.appBar?.elevation =
|
activityBinding?.appBar?.elevation =
|
||||||
when {
|
when {
|
||||||
binding.bottomSheet.extBottomSheet.sheetBehavior.isExpanded() -> 0f
|
binding.bottomSheet.root.sheetBehavior.isExpanded() -> 0f
|
||||||
binding.recycler.canScrollVertically(-1) -> 15f
|
binding.recycler.canScrollVertically(-1) -> 15f
|
||||||
else -> 0f
|
else -> 0f
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.bottomSheet.extBottomSheet.presenter.refreshMigrations()
|
binding.bottomSheet.root.presenter.refreshMigrations()
|
||||||
}
|
}
|
||||||
setBottomPadding()
|
setBottomPadding()
|
||||||
}
|
}
|
||||||
@ -315,15 +317,15 @@ class BrowseController :
|
|||||||
override fun onChangeEnded(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeEnded(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeEnded(handler, type)
|
super.onChangeEnded(handler, type)
|
||||||
if (type.isEnter) {
|
if (type.isEnter) {
|
||||||
binding.bottomSheet.extBottomSheet.canExpand = true
|
binding.bottomSheet.root.canExpand = true
|
||||||
setBottomPadding()
|
setBottomPadding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResumed(activity: Activity) {
|
override fun onActivityResumed(activity: Activity) {
|
||||||
super.onActivityResumed(activity)
|
super.onActivityResumed(activity)
|
||||||
binding.bottomSheet.extBottomSheet?.presenter?.refreshExtensions()
|
binding.bottomSheet.root.presenter.refreshExtensions()
|
||||||
binding.bottomSheet.extBottomSheet?.presenter?.refreshMigrations()
|
binding.bottomSheet.root.presenter.refreshMigrations()
|
||||||
setBottomPadding()
|
setBottomPadding()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +345,7 @@ class BrowseController :
|
|||||||
presenter.updateSources()
|
presenter.updateSources()
|
||||||
|
|
||||||
snackbar = view?.snack(R.string.source_hidden, Snackbar.LENGTH_INDEFINITE) {
|
snackbar = view?.snack(R.string.source_hidden, Snackbar.LENGTH_INDEFINITE) {
|
||||||
anchorView = binding.bottomSheet.extBottomSheet
|
anchorView = binding.bottomSheet.root
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
val newCurrent = preferences.hiddenSources().get()
|
val newCurrent = preferences.hiddenSources().get()
|
||||||
preferences.hiddenSources().set(newCurrent - source.id.toString())
|
preferences.hiddenSources().set(newCurrent - source.id.toString())
|
||||||
@ -391,7 +393,7 @@ class BrowseController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun expandSearch() {
|
override fun expandSearch() {
|
||||||
if (showingExtensions) binding.bottomSheet.extBottomSheet.sheetBehavior?.collapse()
|
if (showingExtensions) binding.bottomSheet.root.sheetBehavior?.collapse()
|
||||||
else activityBinding?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
else activityBinding?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +420,7 @@ class BrowseController :
|
|||||||
// Create query listener which opens the global search view.
|
// Create query listener which opens the global search view.
|
||||||
setOnQueryTextChangeListener(searchView) {
|
setOnQueryTextChangeListener(searchView) {
|
||||||
extQuery = it ?: ""
|
extQuery = it ?: ""
|
||||||
binding.bottomSheet.extBottomSheet.drawExtensions()
|
binding.bottomSheet.root.drawExtensions()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user