Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

kunfei 3 лет назад
Родитель
Сommit
b8e7e83295

+ 2 - 2
app/src/main/java/io/legado/app/help/http/CookieStore.kt

@@ -84,8 +84,8 @@ object CookieStore : CookieManagerInterface {
         }
         val pairArray = cookie.split(semicolonRegex).dropLastWhile { it.isEmpty() }.toTypedArray()
         for (pair in pairArray) {
-            val pairs = pair.split(equalsRegex).dropLastWhile { it.isEmpty() }.toTypedArray()
-            if (pairs.size == 1) {
+            val pairs = pair.split(equalsRegex, 2).dropLastWhile { it.isEmpty() }.toTypedArray()
+            if (pairs.size <= 1) {
                 continue
             }
             val key = pairs[0].trim { it <= ' ' }

+ 0 - 1
app/src/main/java/io/legado/app/model/localBook/LocalBook.kt

@@ -187,7 +187,6 @@ object LocalBook {
                 name = nameAuthor.first,
                 author = nameAuthor.second,
                 originName = fileName,
-                coverUrl = getCoverPath(bookUrl),
                 latestChapterTime = updateTime,
                 order = appDb.bookDao.minOrder - 1
             )

+ 6 - 9
app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt

@@ -51,6 +51,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
     private val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
     private val tocMap = ConcurrentHashMap<String, List<BookChapter>>()
     private var searchCallback: SourceCallback? = null
+    private val emptyBookSource = BookSource()
     val bookMap = ConcurrentHashMap<String, Book>()
     val searchDataFlow = callbackFlow {
 
@@ -113,7 +114,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
     }.flowOn(IO)
 
     @Volatile
-    private var searchIndex = -1
+    private var searchIndex = 0
 
     override fun onCleared() {
         super.onCleared()
@@ -137,7 +138,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
     private fun initSearchPool() {
         searchPool = Executors
             .newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
-        searchIndex = -1
+        searchIndex = 0
     }
 
     fun refresh(): Boolean {
@@ -180,13 +181,14 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
     }
 
     private fun search() {
-        synchronized(this) {
+        val searchIndex = synchronized(this) {
             if (searchIndex >= bookSourceList.lastIndex) {
                 return
             }
             searchIndex++
         }
         val source = bookSourceList[searchIndex]
+        bookSourceList[searchIndex] = emptyBookSource
         val task = execute(context = searchPool!!, executeContext = searchPool!!) {
             val resultBooks = WebBook.searchBookAwait(source, name)
             resultBooks.forEach { searchBook ->
@@ -197,15 +199,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
                     return@forEach
                 }
                 when {
-                    searchBook.latestChapterTitle.isNullOrEmpty() &&
-                            (AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc) -> {
+                    AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc || AppConfig.changeSourceLoadWordCount -> {
                         loadBookInfo(source, searchBook.toBook())
                     }
 
-                    AppConfig.changeSourceLoadWordCount -> {
-                        loadBookToc(source, searchBook.toBook())
-                    }
-
                     else -> {
                         searchCallback?.searchSuccess(searchBook)
                     }

+ 11 - 0
app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@@ -172,6 +172,7 @@ class ReadBookActivity : BaseReadBookActivity(),
     private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } }
     private var bookChanged = false
     private var pageChanged = false
+    private var reloadContent = false
 
     //恢复跳转前进度对话框的交互结果
     private var confirmRestoreProcess: Boolean? = null
@@ -218,6 +219,10 @@ class ReadBookActivity : BaseReadBookActivity(),
         super.onPostCreate(savedInstanceState)
         viewModel.initData(intent) {
             upMenu()
+            if (reloadContent) {
+                reloadContent = false
+                ReadBook.loadContent(resetPageOffset = false)
+            }
         }
     }
 
@@ -225,6 +230,10 @@ class ReadBookActivity : BaseReadBookActivity(),
         super.onNewIntent(intent)
         viewModel.initData(intent ?: return) {
             upMenu()
+            if (reloadContent) {
+                reloadContent = false
+                ReadBook.loadContent(resetPageOffset = false)
+            }
         }
     }
 
@@ -1428,6 +1437,8 @@ class ReadBookActivity : BaseReadBookActivity(),
             if (it) {
                 if (isInitFinish) {
                     ReadBook.loadContent(resetPageOffset = false)
+                } else {
+                    reloadContent = true
                 }
             } else {
                 readView.upContent(resetPageOffset = false)