Selaa lähdekoodia

文件夹样式快速滚动条 #300

HapeLee 1 vuosi sitten
vanhempi
commit
d512800d8e

+ 13 - 0
app/src/main/java/io/legado/app/ui/main/bookshelf/books/BookshelfFragment2.kt

@@ -5,6 +5,7 @@ import android.content.Intent
 import android.os.Build
 import android.os.Build
 import android.os.Bundle
 import android.os.Bundle
 import android.view.View
 import android.view.View
+import android.view.ViewConfiguration
 import androidx.activity.OnBackPressedCallback
 import androidx.activity.OnBackPressedCallback
 import androidx.appcompat.widget.SearchView
 import androidx.appcompat.widget.SearchView
 import androidx.core.app.ActivityOptionsCompat
 import androidx.core.app.ActivityOptionsCompat
@@ -144,6 +145,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
     }
     }
 
 
     private fun initRecyclerView() {
     private fun initRecyclerView() {
+        upFastScrollerBar()
         binding.refreshLayout.setOnRefreshListener {
         binding.refreshLayout.setOnRefreshListener {
             val books = booksAdapter.getBookItems()
             val books = booksAdapter.getBookItems()
             val refreshList = if (AppConfig.bookshelfRefreshingLimit > 0) {
             val refreshList = if (AppConfig.bookshelfRefreshingLimit > 0) {
@@ -188,6 +190,17 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
         }
         }
     }
     }
 
 
+    private fun upFastScrollerBar() {
+        val showBookshelfFastScroller = AppConfig.showBookshelfFastScroller
+        binding.rvBookshelf.setFastScrollEnabled(showBookshelfFastScroller)
+        if (showBookshelfFastScroller) {
+            binding.rvBookshelf.scrollBarSize = 0
+        } else {
+            binding.rvBookshelf.scrollBarSize =
+                ViewConfiguration.get(requireContext()).scaledScrollBarSize
+        }
+    }
+
     override fun upGroup(data: List<BookGroup>) {
     override fun upGroup(data: List<BookGroup>) {
         if (data != bookGroups) {
         if (data != bookGroups) {
             bookGroups = data
             bookGroups = data

+ 15 - 6
app/src/main/res/layout/fragment_bookshelf2.xml

@@ -39,18 +39,27 @@
         android:id="@+id/refresh_layout"
         android:id="@+id/refresh_layout"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_height="match_parent"
-        android:paddingHorizontal="8dp"
         app:layout_behavior="@string/appbar_scrolling_view_behavior">
         app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
 
-        <androidx.recyclerview.widget.RecyclerView
-            android:id="@+id/rv_bookshelf"
+        <FrameLayout
             android:layout_width="match_parent"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:clipToPadding="false"
-            tools:listitem="@layout/item_bookshelf_list" />
+            android:layout_height="match_parent">
 
 
+            <io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
+                android:id="@+id/rv_bookshelf"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"/>
+
+            <io.legado.app.ui.widget.recycler.scroller.FastScroller
+                android:id="@+id/fast_scroller"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="end" />
+
+        </FrameLayout>
     </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
     </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
 
+
     <TextView
     <TextView
         android:id="@+id/tv_empty_msg"
         android:id="@+id/tv_empty_msg"
         android:layout_width="wrap_content"
         android:layout_width="wrap_content"