mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 14:01:52 +01:00
Showing category change via the fastscroll indicator, Library title is now always "Library"
This commit is contained in:
parent
ea0b4c2bc3
commit
60bb7d919d
@ -139,10 +139,7 @@ class LibraryController(
|
||||
private var alwaysShowScroller: Boolean = preferences.alwaysShowSeeker().getOrDefault()
|
||||
|
||||
override fun getTitle(): String? {
|
||||
return if (view != null && presenter.categories.size > 1) presenter.categories.find {
|
||||
it.order == activeCategory
|
||||
}?.name ?: view?.context?.getString(R.string.library)
|
||||
else view?.context?.getString(R.string.library)
|
||||
return view?.context?.getString(R.string.library)
|
||||
}
|
||||
|
||||
private var scrollListener = object : RecyclerView.OnScrollListener() {
|
||||
@ -159,7 +156,22 @@ class LibraryController(
|
||||
if (order != null && order != activeCategory && lastItem == null) {
|
||||
preferences.lastUsedCategory().set(order)
|
||||
activeCategory = order
|
||||
setTitle()
|
||||
if (presenter.categories.size > 1 && dy != 0 && abs(dy) > 75) {
|
||||
val headerItem = getHeader() ?: return
|
||||
val view = fast_scroller.getChildAt(0) ?: return
|
||||
val index = adapter.headerItems.indexOf(headerItem)
|
||||
textAnim?.cancel()
|
||||
textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000)
|
||||
textAnim?.start()
|
||||
|
||||
// fastScroll height * indicator position - center text - fastScroll padding
|
||||
text_view_m.translationY = view.height *
|
||||
(index.toFloat() / (adapter.headerItems.size + 1))
|
||||
- text_view_m.height / 2 + 16.dpToPx
|
||||
text_view_m.translationX = 50f.dpToPx
|
||||
text_view_m.alpha = 1f
|
||||
text_view_m.text = headerItem.category.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +218,7 @@ class LibraryController(
|
||||
super.onViewCreated(view)
|
||||
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
|
||||
if (!::presenter.isInitialized) presenter = LibraryPresenter(this)
|
||||
fast_scroller.translationX = 25f.dpToPx
|
||||
if (!alwaysShowScroller) fast_scroller.translationX = 25f.dpToPx
|
||||
setFastScrollBackground()
|
||||
|
||||
adapter = LibraryCategoryAdapter(this)
|
||||
@ -248,9 +260,22 @@ class LibraryController(
|
||||
textAnim?.start()
|
||||
|
||||
text_view_m.translationY = indicatorCenterY.toFloat() - text_view_m.height / 2
|
||||
text_view_m.translationX = 0f
|
||||
text_view_m.alpha = 1f
|
||||
text_view_m.text = adapter.onCreateBubbleText(itemPosition)
|
||||
val appbar = activity?.appbar
|
||||
|
||||
if (singleCategory) {
|
||||
val order = when (val item = adapter.getItem(itemPosition)) {
|
||||
is LibraryHeaderItem -> item
|
||||
is LibraryItem -> item.header
|
||||
else -> null
|
||||
}?.category?.order
|
||||
if (order != null) {
|
||||
activeCategory = order
|
||||
preferences.lastUsedCategory().set(order)
|
||||
}
|
||||
}
|
||||
appbar?.y = 0f
|
||||
recycler.suppressLayout(true)
|
||||
(recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||
@ -333,6 +358,25 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getHeader(): LibraryHeaderItem? {
|
||||
val position =
|
||||
(recycler.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()
|
||||
if (position > 0) {
|
||||
when (val item = adapter.getItem(position)) {
|
||||
is LibraryHeaderItem -> return item
|
||||
is LibraryItem -> return item.header
|
||||
}
|
||||
} else {
|
||||
val fPosition =
|
||||
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
||||
when (val item = adapter.getItem(fPosition)) {
|
||||
is LibraryHeaderItem -> return item
|
||||
is LibraryItem -> return item.header
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun getCategoryOrder(): Int? {
|
||||
val position =
|
||||
(recycler.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()
|
||||
@ -445,13 +489,12 @@ class LibraryController(
|
||||
adapter.setItems(mangaMap)
|
||||
singleCategory = presenter.categories.size <= 1
|
||||
|
||||
setTitle()
|
||||
progress.gone()
|
||||
if (!freshStart) {
|
||||
justStarted = false
|
||||
if (recycler_layout.alpha == 0f) recycler_layout.animate().alpha(1f).setDuration(500)
|
||||
.start()
|
||||
} else if (justStarted && freshStart) {
|
||||
progress.gone()
|
||||
scrollToHeader(activeCategory)
|
||||
fast_scroller.translationX = 0f
|
||||
view?.post {
|
||||
@ -675,9 +718,6 @@ class LibraryController(
|
||||
) == null
|
||||
) {
|
||||
recycler.scrollBy(0, recycler.paddingTop)
|
||||
view?.post {
|
||||
setTitle()
|
||||
}
|
||||
}
|
||||
activity?.appbar?.y = 0f
|
||||
if (lastItemPosition == toPosition) lastItemPosition = null
|
||||
@ -695,11 +735,11 @@ class LibraryController(
|
||||
}
|
||||
|
||||
override fun onItemReleased(position: Int) {
|
||||
lastItem = null
|
||||
if (adapter.selectedItemCount > 0) {
|
||||
lastItemPosition = null
|
||||
return
|
||||
}
|
||||
lastItem = null
|
||||
destroyActionModeIfNeeded()
|
||||
// if nothing moved
|
||||
if (lastItemPosition == null) return
|
||||
|
@ -55,15 +55,14 @@
|
||||
tools:alpha="1"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:background="@drawable/round_textview_background"
|
||||
android:backgroundTint="@color/md_grey_800_50"
|
||||
android:padding="12dp"
|
||||
android:backgroundTint="@color/md_grey_800_85"
|
||||
android:padding="10dp"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintEnd_toStartOf="@id/fast_scroller"
|
||||
app:layout_constraintTop_toTopOf="@id/fast_scroller"
|
||||
tools:text="sdfsdf" />
|
||||
tools:text="Category" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<eu.kanade.tachiyomi.widget.EmptyView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -56,7 +56,7 @@
|
||||
tools:alpha="1"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:background="@drawable/round_textview_background"
|
||||
android:backgroundTint="@color/md_grey_800_50"
|
||||
android:backgroundTint="@color/md_grey_800_85"
|
||||
android:padding="8dp"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintEnd_toStartOf="@id/fast_scroller"
|
||||
|
@ -71,7 +71,7 @@
|
||||
<color name="md_grey_50">#FAFAFA</color>
|
||||
<color name="md_grey_200">#CCCCCC</color>
|
||||
<color name="md_grey_800">#424242</color>
|
||||
<color name="md_grey_800_50">#CF424242</color>
|
||||
<color name="md_grey_800_85">#DF424242</color>
|
||||
|
||||
<color name="md_blue_A200_50">#80448AFF</color>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user