Horis há 3 anos atrás
pai
commit
35bfacfa38

+ 2 - 2
app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@@ -180,10 +180,10 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
         }
     }
 
-    fun postUpBooksLiveData() {
+    fun postUpBooksLiveData(reset: Boolean = false) {
         if (AppConfig.showWaitUpCount) {
             onUpBooksLiveData.postValue(waitUpTocBooks.size + onUpTocBooks.size)
-        } else {
+        } else if (reset) {
             onUpBooksLiveData.postValue(0)
         }
     }

+ 1 - 1
app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt

@@ -156,7 +156,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
                     }
                     if (AppConfig.showWaitUpCount != swShowWaitUpBooks.isChecked) {
                         AppConfig.showWaitUpCount = swShowWaitUpBooks.isChecked
-                        activityViewModel.postUpBooksLiveData()
+                        activityViewModel.postUpBooksLiveData(true)
                     }
                     var changed = false
                     if (bookshelfLayout != rgLayout.getCheckedIndex()) {

+ 1 - 1
app/src/main/java/io/legado/app/utils/ContextExtensions.kt

@@ -43,7 +43,7 @@ inline fun <reified A : Activity> Context.startActivity(configIntent: Intent.()
 }
 
 inline fun <reified T : Service> Context.startService(configIntent: Intent.() -> Unit = {}) {
-    ContextCompat.startForegroundService(this, Intent(this, T::class.java).apply(configIntent))
+    startService(Intent(this, T::class.java).apply(configIntent))
 }
 
 inline fun <reified T : Service> Context.stopService() {