Xwite 3 лет назад
Родитель
Сommit
649c74605c

+ 14 - 4
app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@@ -25,6 +25,7 @@ import io.legado.app.help.config.AppConfig
 import io.legado.app.help.config.LocalConfig
 import io.legado.app.help.config.LocalConfig
 import io.legado.app.lib.dialogs.alert
 import io.legado.app.lib.dialogs.alert
 import io.legado.app.lib.dialogs.selector
 import io.legado.app.lib.dialogs.selector
+import io.legado.app.lib.theme.accentColor
 import io.legado.app.lib.theme.backgroundColor
 import io.legado.app.lib.theme.backgroundColor
 import io.legado.app.lib.theme.bottomBackground
 import io.legado.app.lib.theme.bottomBackground
 import io.legado.app.lib.theme.getPrimaryTextColor
 import io.legado.app.lib.theme.getPrimaryTextColor
@@ -111,6 +112,11 @@ class BookInfoActivity :
     @SuppressLint("PrivateResource")
     @SuppressLint("PrivateResource")
     override fun onActivityCreated(savedInstanceState: Bundle?) {
     override fun onActivityCreated(savedInstanceState: Bundle?) {
         binding.titleBar.setBackgroundResource(R.color.transparent)
         binding.titleBar.setBackgroundResource(R.color.transparent)
+        binding.refreshLayout.setColorSchemeColors(accentColor)
+        binding.refreshLayout.setOnRefreshListener {
+            binding.refreshLayout.isRefreshing = false
+            refreshBook()
+        }
         binding.arcView.setBgColor(backgroundColor)
         binding.arcView.setBgColor(backgroundColor)
         binding.llInfo.setBackgroundColor(backgroundColor)
         binding.llInfo.setBackgroundColor(backgroundColor)
         binding.scrollView.setBackgroundColor(backgroundColor)
         binding.scrollView.setBackgroundColor(backgroundColor)
@@ -169,10 +175,7 @@ class BookInfoActivity :
                 }
                 }
             }
             }
             R.id.menu_refresh -> {
             R.id.menu_refresh -> {
-                upLoading(true)
-                viewModel.getBook()?.let {
-                    viewModel.refreshBook(it)
-                }
+                refreshBook()
             }
             }
             R.id.menu_login -> viewModel.bookSource?.let {
             R.id.menu_login -> viewModel.bookSource?.let {
                 startActivity<SourceLoginActivity> {
                 startActivity<SourceLoginActivity> {
@@ -236,6 +239,13 @@ class BookInfoActivity :
         }
         }
     }
     }
 
 
+    private fun refreshBook() {
+        upLoading(true)
+        viewModel.getBook()?.let {
+            viewModel.refreshBook(it)
+        }
+    }
+
     private fun upLoadBook(
     private fun upLoadBook(
         book: Book,
         book: Book,
         bookWebDav: RemoteBookWebDav? = AppWebDav.defaultBookWebDav
         bookWebDav: RemoteBookWebDav? = AppWebDav.defaultBookWebDav

+ 35 - 26
app/src/main/res/layout/activity_book_info.xml

@@ -29,39 +29,48 @@
             app:title="@string/book_info"
             app:title="@string/book_info"
             app:themeMode="dark" />
             app:themeMode="dark" />
 
 
-        <RelativeLayout
+        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+            android:id="@+id/refresh_layout"
             android:layout_width="match_parent"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="8dp">
+            android:layout_height="0dp"
+            app:layout_constraintTop_toBottomOf="@+id/title_bar"
+            app:layout_constraintBottom_toBottomOf="parent">
 
 
-            <io.legado.app.ui.widget.image.ArcView
-                android:id="@+id/arc_view"
-                android:layout_marginTop="90dp"
+            <RelativeLayout
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
-                android:layout_height="78dp"
-                app:arcDirectionTop="true"
-                app:arcHeight="36dp"
-                app:bgColor="@color/background" />
-
-            <androidx.cardview.widget.CardView
-                android:layout_margin="3dp"
-                android:layout_centerHorizontal="true"
-                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_height="wrap_content"
-                app:cardCornerRadius="5dp"
-                app:cardElevation="8dp">
+                android:layout_marginTop="8dp">
+
+                <io.legado.app.ui.widget.image.ArcView
+                    android:id="@+id/arc_view"
+                    android:layout_marginTop="90dp"
+                    android:layout_width="match_parent"
+                    android:layout_height="78dp"
+                    app:arcDirectionTop="true"
+                    app:arcHeight="36dp"
+                    app:bgColor="@color/background" />
+
+                <androidx.cardview.widget.CardView
+                    android:layout_margin="3dp"
+                    android:layout_centerHorizontal="true"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    app:cardCornerRadius="5dp"
+                    app:cardElevation="8dp">
+
+                    <io.legado.app.ui.widget.image.CoverImageView
+                        android:id="@+id/iv_cover"
+                        android:layout_width="110dp"
+                        android:layout_height="160dp"
+                        android:contentDescription="@string/img_cover"
+                        android:scaleType="centerCrop"
+                        android:src="@drawable/image_cover_default" />
 
 
-                <io.legado.app.ui.widget.image.CoverImageView
-                    android:id="@+id/iv_cover"
-                    android:layout_width="110dp"
-                    android:layout_height="160dp"
-                    android:contentDescription="@string/img_cover"
-                    android:scaleType="centerCrop"
-                    android:src="@drawable/image_cover_default" />
+                </androidx.cardview.widget.CardView>
 
 
-            </androidx.cardview.widget.CardView>
+            </RelativeLayout>
 
 
-        </RelativeLayout>
+        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
 
         <ScrollView
         <ScrollView
             android:id="@+id/scroll_view"
             android:id="@+id/scroll_view"