mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 01:48:24 +01:00
Give view pager unique ids, avoiding subtle bugs
This commit is contained in:
parent
8bcb14c65d
commit
08baf798aa
@ -138,8 +138,8 @@ class LibraryController(
|
||||
super.onViewCreated(view)
|
||||
|
||||
adapter = LibraryAdapter(this)
|
||||
view_pager.adapter = adapter
|
||||
view_pager.pageSelections().skip(1).subscribeUntilDestroy {
|
||||
library_pager.adapter = adapter
|
||||
library_pager.pageSelections().skip(1).subscribeUntilDestroy {
|
||||
preferences.lastUsedCategory().set(it)
|
||||
activeCategory = it
|
||||
}
|
||||
@ -158,7 +158,7 @@ class LibraryController(
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
activity?.tabs?.setupWithViewPager(view_pager)
|
||||
activity?.tabs?.setupWithViewPager(library_pager)
|
||||
presenter.subscribeLibrary()
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ class LibraryController(
|
||||
|
||||
// Get the current active category.
|
||||
val activeCat = if (adapter.categories.isNotEmpty())
|
||||
view_pager.currentItem
|
||||
library_pager.currentItem
|
||||
else
|
||||
activeCategory
|
||||
|
||||
@ -240,14 +240,14 @@ class LibraryController(
|
||||
adapter.categories = categories
|
||||
|
||||
// Restore active category.
|
||||
view_pager.setCurrentItem(activeCat, false)
|
||||
library_pager.setCurrentItem(activeCat, false)
|
||||
|
||||
tabsVisibilityRelay.call(categories.size > 1)
|
||||
|
||||
// Delay the scroll position to allow the view to be properly measured.
|
||||
view.post {
|
||||
if (isAttached) {
|
||||
activity?.tabs?.setScrollPosition(view_pager.currentItem, 0f, true)
|
||||
activity?.tabs?.setScrollPosition(library_pager.currentItem, 0f, true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,11 +292,11 @@ class LibraryController(
|
||||
private fun reattachAdapter() {
|
||||
val adapter = adapter ?: return
|
||||
|
||||
val position = view_pager.currentItem
|
||||
val position = library_pager.currentItem
|
||||
|
||||
adapter.recycle = false
|
||||
view_pager.adapter = adapter
|
||||
view_pager.currentItem = position
|
||||
library_pager.adapter = adapter
|
||||
library_pager.currentItem = position
|
||||
adapter.recycle = true
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ class MangaController : RxController, TabbedController {
|
||||
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
||||
|
||||
adapter = MangaDetailAdapter()
|
||||
view_pager.offscreenPageLimit = 3
|
||||
view_pager.adapter = adapter
|
||||
manga_pager.offscreenPageLimit = 3
|
||||
manga_pager.adapter = adapter
|
||||
|
||||
if (!fromCatalogue)
|
||||
view_pager.currentItem = CHAPTERS_CONTROLLER
|
||||
manga_pager.currentItem = CHAPTERS_CONTROLLER
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
@ -102,7 +102,7 @@ class MangaController : RxController, TabbedController {
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
activity?.tabs?.setupWithViewPager(view_pager)
|
||||
activity?.tabs?.setupWithViewPager(manga_pager)
|
||||
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ abstract class PagerReader : BaseReader() {
|
||||
this.pager = pager.apply {
|
||||
setLayoutParams(ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT))
|
||||
setOffscreenPageLimit(1)
|
||||
setId(R.id.view_pager)
|
||||
setId(R.id.reader_pager)
|
||||
setOnChapterBoundariesOutListener(object : OnChapterBoundariesOutListener {
|
||||
override fun onFirstPageOutEvent() {
|
||||
readerActivity.requestPreviousChapter()
|
||||
|
@ -8,7 +8,7 @@
|
||||
<android.support.v4.view.ViewPager
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/view_pager"/>
|
||||
android:id="@+id/library_pager"/>
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
android:id="@+id/empty_view"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.view.ViewPager
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/view_pager"
|
||||
android:id="@+id/manga_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
@ -3,4 +3,6 @@
|
||||
|
||||
<item name="catalogue_filter_sort_group" type="id"/>
|
||||
<item name="catalogue_filter_sort_item" type="id"/>
|
||||
|
||||
<item name="reader_pager" type="id"/>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user