优化
This commit is contained in:
@@ -318,12 +318,15 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
||||
chapters: List<BookChapter>
|
||||
) = coroutineScope {
|
||||
val chapterIndex = if (fromReadBookActivity) {
|
||||
oldBook?.let {
|
||||
BookHelp.getDurChapter(it, chapters)
|
||||
} ?: chapters.lastIndex
|
||||
} else chapters.lastIndex
|
||||
BookHelp.getDurChapter(oldBook!!, chapters)
|
||||
} else {
|
||||
chapters.lastIndex
|
||||
}
|
||||
val bookChapter = chapters[chapterIndex]
|
||||
val title = bookChapter.title.trim()
|
||||
var title = bookChapter.title.trim()
|
||||
if (title.length > 20) {
|
||||
title = title.substring(0, 20) + "…"
|
||||
}
|
||||
val startTime = System.currentTimeMillis()
|
||||
val pair = try {
|
||||
val nextChapterUrl = chapters.getOrNull(chapterIndex + 1)?.url
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.legado.app.help.config.SourceConfig
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.help.http.newCallStrResponse
|
||||
import io.legado.app.help.http.okHttpClient
|
||||
import io.legado.app.help.source.SourceHelp
|
||||
import io.legado.app.help.source.clearExploreKindsCache
|
||||
import io.legado.app.help.storage.ImportOldData
|
||||
import io.legado.app.model.SharedJsScope
|
||||
@@ -63,8 +64,12 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
|
||||
}
|
||||
}
|
||||
bookSource?.let {
|
||||
appDb.bookSourceDao.delete(it)
|
||||
SourceConfig.removeSource(it.bookSourceUrl)
|
||||
if (it.bookSourceUrl != source.bookSourceUrl) {
|
||||
SourceHelp.deleteBookSource(it.bookSourceUrl)
|
||||
} else {
|
||||
appDb.bookSourceDao.delete(it)
|
||||
SourceConfig.removeSource(it.bookSourceUrl)
|
||||
}
|
||||
}
|
||||
appDb.bookSourceDao.insert(source)
|
||||
bookSource = source
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.legado.app.base.BaseViewModel
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.RssSource
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.AppCacheManager
|
||||
import io.legado.app.help.RuleComplete
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.utils.GSON
|
||||
@@ -46,6 +47,8 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
|
||||
if (it.sourceUrl != source.sourceUrl) {
|
||||
appDb.rssStarDao.updateOrigin(source.sourceUrl, it.sourceUrl)
|
||||
appDb.rssArticleDao.updateOrigin(source.sourceUrl, it.sourceUrl)
|
||||
appDb.cacheDao.deleteSourceVariables(it.sourceUrl)
|
||||
AppCacheManager.clearSourceVariables()
|
||||
}
|
||||
}
|
||||
appDb.rssSourceDao.insert(source)
|
||||
|
||||
Reference in New Issue
Block a user