Fixed #469 - Reader chapters clickable while collasped

This commit is contained in:
Jay 2020-06-06 16:01:20 -04:00
parent 14ec89f654
commit f5f4b8a119

View File

@ -59,6 +59,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
post { post {
chapter_recycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f chapter_recycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f
chapter_recycler.isClickable = sheetBehavior.isExpanded()
chapter_recycler.isFocusable = sheetBehavior.isExpanded()
} }
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
@ -95,6 +97,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
webview_button.alpha = 1f webview_button.alpha = 1f
if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary
} }
chapter_recycler.isClickable = state == BottomSheetBehavior.STATE_EXPANDED
chapter_recycler.isFocusable = state == BottomSheetBehavior.STATE_EXPANDED
webview_button.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) webview_button.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED)
chapters_button.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) chapters_button.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED)
} }
@ -103,12 +107,16 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
adapter = FastAdapter.with(itemAdapter) adapter = FastAdapter.with(itemAdapter)
chapter_recycler.adapter = adapter chapter_recycler.adapter = adapter
adapter?.onClickListener = { _, _, item, _ -> adapter?.onClickListener = { _, _, item, _ ->
if (!sheetBehavior.isExpanded()) {
false
} else {
if (item.chapter.id != presenter.getCurrentChapter()?.chapter?.id) { if (item.chapter.id != presenter.getCurrentChapter()?.chapter?.id) {
shouldCollapse = false shouldCollapse = false
presenter.loadChapter(item.chapter) presenter.loadChapter(item.chapter)
} }
true true
} }
}
adapter?.addEventHook(object : ClickEventHook<ReaderChapterItem>() { adapter?.addEventHook(object : ClickEventHook<ReaderChapterItem>() {
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? { override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
return if (viewHolder is ReaderChapterItem.ViewHolder) { return if (viewHolder is ReaderChapterItem.ViewHolder) {