mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 23:29:16 +01:00
Fix scroll position with many categories. Closes #332
This commit is contained in:
parent
dbec4fc15e
commit
2d1e85f280
@ -139,6 +139,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
tabs.setupWithViewPager(null)
|
||||||
tabs.visibility = View.GONE
|
tabs.visibility = View.GONE
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
@ -261,18 +262,12 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
|||||||
|
|
||||||
// Set the categories
|
// Set the categories
|
||||||
adapter.categories = categories
|
adapter.categories = categories
|
||||||
tabs.setupWithViewPager(view_pager)
|
|
||||||
tabs.visibility = if (categories.size <= 1) View.GONE else View.VISIBLE
|
tabs.visibility = if (categories.size <= 1) View.GONE else View.VISIBLE
|
||||||
|
|
||||||
// Restore active category.
|
// Restore active category.
|
||||||
view_pager.setCurrentItem(activeCat, false)
|
view_pager.setCurrentItem(activeCat, false)
|
||||||
if (tabs.tabCount > 0) {
|
// Delay the scroll position to allow the view to be properly measured.
|
||||||
// Prevent IndexOutOfBoundsException
|
view_pager.post { tabs.setScrollPosition(view_pager.currentItem, 0f, true) }
|
||||||
if (tabs.tabCount <= view_pager.currentItem) {
|
|
||||||
view_pager.currentItem = (tabs.tabCount - 1)
|
|
||||||
}
|
|
||||||
tabs.getTabAt(view_pager.currentItem)?.select()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the manga map to child fragments after the adapter is updated.
|
// Send the manga map to child fragments after the adapter is updated.
|
||||||
presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap))
|
presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap))
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
<include layout="@layout/toolbar"/>
|
<include layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<android.support.design.widget.TabLayout
|
<android.support.design.widget.TabLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/tabs"
|
android:id="@+id/tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user