Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -84,8 +84,8 @@ object CookieStore : CookieManagerInterface {
|
|||||||
}
|
}
|
||||||
val pairArray = cookie.split(semicolonRegex).dropLastWhile { it.isEmpty() }.toTypedArray()
|
val pairArray = cookie.split(semicolonRegex).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
for (pair in pairArray) {
|
for (pair in pairArray) {
|
||||||
val pairs = pair.split(equalsRegex).dropLastWhile { it.isEmpty() }.toTypedArray()
|
val pairs = pair.split(equalsRegex, 2).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
if (pairs.size == 1) {
|
if (pairs.size <= 1) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val key = pairs[0].trim { it <= ' ' }
|
val key = pairs[0].trim { it <= ' ' }
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ object LocalBook {
|
|||||||
name = nameAuthor.first,
|
name = nameAuthor.first,
|
||||||
author = nameAuthor.second,
|
author = nameAuthor.second,
|
||||||
originName = fileName,
|
originName = fileName,
|
||||||
coverUrl = getCoverPath(bookUrl),
|
|
||||||
latestChapterTime = updateTime,
|
latestChapterTime = updateTime,
|
||||||
order = appDb.bookDao.minOrder - 1
|
order = appDb.bookDao.minOrder - 1
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
private val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
|
private val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
|
||||||
private val tocMap = ConcurrentHashMap<String, List<BookChapter>>()
|
private val tocMap = ConcurrentHashMap<String, List<BookChapter>>()
|
||||||
private var searchCallback: SourceCallback? = null
|
private var searchCallback: SourceCallback? = null
|
||||||
|
private val emptyBookSource = BookSource()
|
||||||
val bookMap = ConcurrentHashMap<String, Book>()
|
val bookMap = ConcurrentHashMap<String, Book>()
|
||||||
val searchDataFlow = callbackFlow {
|
val searchDataFlow = callbackFlow {
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
}.flowOn(IO)
|
}.flowOn(IO)
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var searchIndex = -1
|
private var searchIndex = 0
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
@@ -137,7 +138,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
private fun initSearchPool() {
|
private fun initSearchPool() {
|
||||||
searchPool = Executors
|
searchPool = Executors
|
||||||
.newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
|
.newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
|
||||||
searchIndex = -1
|
searchIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refresh(): Boolean {
|
fun refresh(): Boolean {
|
||||||
@@ -180,13 +181,14 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun search() {
|
private fun search() {
|
||||||
synchronized(this) {
|
val searchIndex = synchronized(this) {
|
||||||
if (searchIndex >= bookSourceList.lastIndex) {
|
if (searchIndex >= bookSourceList.lastIndex) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
searchIndex++
|
searchIndex++
|
||||||
}
|
}
|
||||||
val source = bookSourceList[searchIndex]
|
val source = bookSourceList[searchIndex]
|
||||||
|
bookSourceList[searchIndex] = emptyBookSource
|
||||||
val task = execute(context = searchPool!!, executeContext = searchPool!!) {
|
val task = execute(context = searchPool!!, executeContext = searchPool!!) {
|
||||||
val resultBooks = WebBook.searchBookAwait(source, name)
|
val resultBooks = WebBook.searchBookAwait(source, name)
|
||||||
resultBooks.forEach { searchBook ->
|
resultBooks.forEach { searchBook ->
|
||||||
@@ -197,15 +199,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
searchBook.latestChapterTitle.isNullOrEmpty() &&
|
AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc || AppConfig.changeSourceLoadWordCount -> {
|
||||||
(AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc) -> {
|
|
||||||
loadBookInfo(source, searchBook.toBook())
|
loadBookInfo(source, searchBook.toBook())
|
||||||
}
|
}
|
||||||
|
|
||||||
AppConfig.changeSourceLoadWordCount -> {
|
|
||||||
loadBookToc(source, searchBook.toBook())
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
searchCallback?.searchSuccess(searchBook)
|
searchCallback?.searchSuccess(searchBook)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } }
|
private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } }
|
||||||
private var bookChanged = false
|
private var bookChanged = false
|
||||||
private var pageChanged = false
|
private var pageChanged = false
|
||||||
|
private var reloadContent = false
|
||||||
|
|
||||||
//恢复跳转前进度对话框的交互结果
|
//恢复跳转前进度对话框的交互结果
|
||||||
private var confirmRestoreProcess: Boolean? = null
|
private var confirmRestoreProcess: Boolean? = null
|
||||||
@@ -218,6 +219,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
super.onPostCreate(savedInstanceState)
|
super.onPostCreate(savedInstanceState)
|
||||||
viewModel.initData(intent) {
|
viewModel.initData(intent) {
|
||||||
upMenu()
|
upMenu()
|
||||||
|
if (reloadContent) {
|
||||||
|
reloadContent = false
|
||||||
|
ReadBook.loadContent(resetPageOffset = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +230,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
viewModel.initData(intent ?: return) {
|
viewModel.initData(intent ?: return) {
|
||||||
upMenu()
|
upMenu()
|
||||||
|
if (reloadContent) {
|
||||||
|
reloadContent = false
|
||||||
|
ReadBook.loadContent(resetPageOffset = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1428,6 +1437,8 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
if (it) {
|
if (it) {
|
||||||
if (isInitFinish) {
|
if (isInitFinish) {
|
||||||
ReadBook.loadContent(resetPageOffset = false)
|
ReadBook.loadContent(resetPageOffset = false)
|
||||||
|
} else {
|
||||||
|
reloadContent = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
readView.upContent(resetPageOffset = false)
|
readView.upContent(resetPageOffset = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user