mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 07:15:10 +01:00
Collaspe chapter sheet when touching outside of chapter sheet
Which fixes the wonky logic when switching chapters in it
This commit is contained in:
parent
008753e7e4
commit
c43d5f01fa
@ -388,6 +388,14 @@ class ReaderActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.touchView.setOnTouchListener { v, event ->
|
||||||
|
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||||
|
if (binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) {
|
||||||
|
binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
val readerNavGestureDetector = ReaderNavGestureDetector(this)
|
val readerNavGestureDetector = ReaderNavGestureDetector(this)
|
||||||
val gestureDetector = GestureDetectorCompat(this, readerNavGestureDetector)
|
val gestureDetector = GestureDetectorCompat(this, readerNavGestureDetector)
|
||||||
with(binding.readerNav) {
|
with(binding.readerNav) {
|
||||||
@ -680,7 +688,7 @@ class ReaderActivity :
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun onPageSelected(page: ReaderPage) {
|
fun onPageSelected(page: ReaderPage) {
|
||||||
val newChapter = presenter.onPageSelected(page)
|
presenter.onPageSelected(page)
|
||||||
val pages = page.chapter.pages ?: return
|
val pages = page.chapter.pages ?: return
|
||||||
|
|
||||||
val currentPage = page.number
|
val currentPage = page.number
|
||||||
@ -696,14 +704,9 @@ class ReaderActivity :
|
|||||||
binding.readerNav.leftPageText.text = currentPage.toString()
|
binding.readerNav.leftPageText.text = currentPage.toString()
|
||||||
binding.readerNav.rightPageText.text = totalPages.toString()
|
binding.readerNav.rightPageText.text = totalPages.toString()
|
||||||
}
|
}
|
||||||
if (!newChapter && binding.chaptersSheet.chaptersBottomSheet.shouldCollapse && binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) {
|
|
||||||
binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse()
|
|
||||||
}
|
|
||||||
if (binding.chaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id) {
|
if (binding.chaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id) {
|
||||||
binding.chaptersSheet.chaptersBottomSheet.refreshList()
|
binding.chaptersSheet.chaptersBottomSheet.refreshList()
|
||||||
}
|
}
|
||||||
binding.chaptersSheet.chaptersBottomSheet.shouldCollapse = true
|
|
||||||
|
|
||||||
// Set seekbar progress
|
// Set seekbar progress
|
||||||
binding.readerNav.pageSeekbar.max = pages.lastIndex
|
binding.readerNav.pageSeekbar.max = pages.lastIndex
|
||||||
binding.readerNav.pageSeekbar.progress = page.index
|
binding.readerNav.pageSeekbar.progress = page.index
|
||||||
|
@ -458,8 +458,8 @@ class ReaderPresenter(
|
|||||||
* read, update tracking services, enqueue downloaded chapter deletion, and updating the active chapter if this
|
* read, update tracking services, enqueue downloaded chapter deletion, and updating the active chapter if this
|
||||||
* [page]'s chapter is different from the currently active.
|
* [page]'s chapter is different from the currently active.
|
||||||
*/
|
*/
|
||||||
fun onPageSelected(page: ReaderPage): Boolean {
|
fun onPageSelected(page: ReaderPage) {
|
||||||
val currentChapters = viewerChaptersRelay.value ?: return false
|
val currentChapters = viewerChaptersRelay.value ?: return
|
||||||
|
|
||||||
val selectedChapter = page.chapter
|
val selectedChapter = page.chapter
|
||||||
|
|
||||||
@ -477,9 +477,7 @@ class ReaderPresenter(
|
|||||||
Timber.d("Setting ${selectedChapter.chapter.url} as active")
|
Timber.d("Setting ${selectedChapter.chapter.url} as active")
|
||||||
onChapterChanged(currentChapters.currChapter)
|
onChapterChanged(currentChapters.currChapter)
|
||||||
loadNewChapter(selectedChapter)
|
loadNewChapter(selectedChapter)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,6 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
lateinit var presenter: ReaderPresenter
|
lateinit var presenter: ReaderPresenter
|
||||||
var adapter: FastAdapter<ReaderChapterItem>? = null
|
var adapter: FastAdapter<ReaderChapterItem>? = null
|
||||||
private val itemAdapter = ItemAdapter<ReaderChapterItem>()
|
private val itemAdapter = ItemAdapter<ReaderChapterItem>()
|
||||||
var shouldCollapse = true
|
|
||||||
var selectedChapterId = -1L
|
var selectedChapterId = -1L
|
||||||
|
|
||||||
var loadingPos = 0
|
var loadingPos = 0
|
||||||
@ -98,7 +97,6 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
|
|
||||||
override fun onStateChanged(p0: View, state: Int) {
|
override fun onStateChanged(p0: View, state: Int) {
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
shouldCollapse = true
|
|
||||||
sheetBehavior?.isHideable = false
|
sheetBehavior?.isHideable = false
|
||||||
(binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
(binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||||
adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0,
|
adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0,
|
||||||
@ -136,7 +134,6 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
activity.binding.readerNav.leftChapter.invisible()
|
activity.binding.readerNav.leftChapter.invisible()
|
||||||
activity.binding.readerNav.rightChapter.invisible()
|
activity.binding.readerNav.rightChapter.invisible()
|
||||||
|
|
||||||
shouldCollapse = false
|
|
||||||
presenter.loadChapter(item.chapter)
|
presenter.loadChapter(item.chapter)
|
||||||
loadingPos = position
|
loadingPos = position
|
||||||
val itemView = (binding.chapterRecycler.findViewHolderForAdapterPosition(position) as? ReaderChapterItem.ViewHolder)?.binding
|
val itemView = (binding.chapterRecycler.findViewHolderForAdapterPosition(position) as? ReaderChapterItem.ViewHolder)?.binding
|
||||||
|
@ -63,6 +63,12 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/touch_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/nav_layout"
|
android:id="@+id/nav_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user