pull/1336/head
gedoor 3 years ago
parent 6b38f6b118
commit b9dce6051c
  1. 2
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt
  2. 3
      app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt
  3. 3
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  4. 3
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  5. 3
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  6. 3
      app/src/main/java/io/legado/app/model/webBook/BookList.kt
  7. 5
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  8. 3
      app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt
  9. 5
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  10. 3
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
  11. 13
      app/src/main/java/io/legado/app/ui/association/OnLineImportViewModel.kt
  12. 3
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  13. 3
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt
  14. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt

@ -89,7 +89,7 @@ object AppWebDav {
}
}
} else {
throw Exception("Web dav no back up file")
throw NoStackTraceException("Web dav no back up file")
}
}

@ -5,6 +5,7 @@ import io.legado.app.R
import io.legado.app.data.entities.RssArticle
import io.legado.app.data.entities.RssSource
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
@ -26,7 +27,7 @@ object RssParserByRule {
val sourceUrl = rssSource.sourceUrl
var nextUrl: String? = null
if (body.isNullOrBlank()) {
throw Exception(
throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, rssSource.sourceUrl)
)
}

@ -7,6 +7,7 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.TocRule
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.TocEmptyException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
@ -30,7 +31,7 @@ object BookChapterList {
baseUrl: String,
body: String?
): List<BookChapter> {
body ?: throw Exception(
body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl)
)
val chapterList = ArrayList<BookChapter>()

@ -9,6 +9,7 @@ import io.legado.app.data.entities.rule.ContentRule
import io.legado.app.help.BookHelp
import io.legado.app.model.ContentEmptyException
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter
@ -34,7 +35,7 @@ object BookContent {
body: String?,
nextChapterUrl: String? = null
): String {
body ?: throw Exception(
body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl)
)
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")

@ -5,6 +5,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.NetworkUtils
@ -25,7 +26,7 @@ object BookInfo {
body: String?,
canReName: Boolean,
) {
body ?: throw Exception(
body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl)
)
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")

@ -7,6 +7,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.data.entities.rule.BookListRule
import io.legado.app.help.BookHelp
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter
@ -28,7 +29,7 @@ object BookList {
body: String?,
isSearch: Boolean = true,
): ArrayList<SearchBook> {
body ?: throw Exception(
body ?: throw NoStackTraceException(
appCtx.getString(
R.string.error_get_web_content,
analyzeUrl.ruleUrl

@ -13,6 +13,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.model.CheckSource
import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.webBook.WebBook
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.utils.activityPendingIntent
@ -128,7 +129,7 @@ class CheckSourceService : BaseService() {
}
}
if (url.isNullOrBlank()) {
throw Exception("搜索内容为空并且没有发现")
throw NoStackTraceException("搜索内容为空并且没有发现")
}
books = WebBook.exploreBookAwait(this, source, url)
}
@ -137,7 +138,7 @@ class CheckSourceService : BaseService() {
val content =
WebBook.getContentAwait(this, source, book, toc.first(), toc.getOrNull(1)?.url)
if (content.isBlank()) {
throw Exception("正文内容为空")
throw NoStackTraceException("正文内容为空")
}
}.timeout(180000L)
.onError(searchCoroutine) {

@ -5,6 +5,7 @@ import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData
import io.legado.app.base.BaseViewModel
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.isJson
import io.legado.app.utils.printOnDebug
@ -49,7 +50,7 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica
}
val book = LocalBook.importFile(uri)
openBookLiveData.postValue(book.bookUrl)
} ?: throw Exception("文件不存在")
} ?: throw NoStackTraceException("文件不存在")
} else {
onLineImportLive.postValue(uri)
}

@ -15,6 +15,7 @@ import io.legado.app.help.SourceHelp
import io.legado.app.help.http.newCall
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.*
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
@ -114,7 +115,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
mText.isAbsUrl() -> {
importSourceUrl(mText)
}
else -> throw Exception(context.getString(R.string.wrong_format))
else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
}
}.onError {
it.printOnDebug()
@ -144,7 +145,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
}
}
else -> {
throw Exception(context.getString(R.string.wrong_format))
throw NoStackTraceException(context.getString(R.string.wrong_format))
}
}
}

@ -13,6 +13,7 @@ import io.legado.app.help.SourceHelp
import io.legado.app.help.http.newCall
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.*
class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
@ -111,7 +112,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
mText.isAbsUrl() -> {
importSourceUrl(mText)
}
else -> throw Exception(context.getString(R.string.wrong_format))
else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
}
}.onError {
errorLiveData.postValue("ImportError:${it.localizedMessage}")

@ -12,6 +12,7 @@ import io.legado.app.help.ThemeConfig
import io.legado.app.help.http.newCall
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.fromJsonObject
@ -56,11 +57,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
if (json.isJsonArray()) {
GSON.fromJsonArray<TxtTocRule>(json)?.let {
appDb.txtTocRuleDao.insert(*it.toTypedArray())
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
} else {
GSON.fromJsonObject<TxtTocRule>(json)?.let {
appDb.txtTocRuleDao.insert(it)
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
}
}.onSuccess {
finally.invoke(context.getString(R.string.success), "导入Txt规则成功")
@ -78,12 +79,12 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
GSON.fromJsonArray<HttpTTS>(json)?.let {
appDb.httpTTSDao.insert(*it.toTypedArray())
return@execute it.size
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
} else {
GSON.fromJsonObject<HttpTTS>(json)?.let {
appDb.httpTTSDao.insert(it)
return@execute 1
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
}
}.onSuccess {
finally.invoke(context.getString(R.string.success), "导入${it}朗读引擎")
@ -100,11 +101,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
if (json.isJsonArray()) {
GSON.fromJsonArray<ThemeConfig.Config>(json)?.forEach {
ThemeConfig.addConfig(it)
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
} else {
GSON.fromJsonObject<ThemeConfig.Config>(json)?.let {
ThemeConfig.addConfig(it)
} ?: throw Exception("格式不对")
} ?: throw NoStackTraceException("格式不对")
}
}.onSuccess {
finally.invoke(context.getString(R.string.success), "导入主题成功")

@ -14,6 +14,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.help.storage.AppWebDav
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.ReadAloud
import io.legado.app.model.ReadBook
import io.legado.app.model.localBook.LocalBook
@ -199,7 +200,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
WebBook.preciseSearch(this, sources, name, author)?.let {
it.second.upInfoFromOld(ReadBook.book)
changeTo(it.first, it.second)
} ?: throw Exception("自动换源失败")
} ?: throw NoStackTraceException("自动换源失败")
}.onStart {
ReadBook.upMsg(context.getString(R.string.source_auto_changing))
}.onError {

@ -10,6 +10,7 @@ import io.legado.app.help.DefaultData
import io.legado.app.help.http.newCall
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.*
class SpeakEngineViewModel(application: Application) : BaseViewModel(application) {
@ -61,7 +62,7 @@ class SpeakEngineViewModel(application: Application) : BaseViewModel(application
}
}
else -> {
throw Exception("格式不对")
throw NoStackTraceException("格式不对")
}
}
}

@ -9,6 +9,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.help.http.newCall
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.IO
@ -50,7 +51,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
it.save()
successCount++
}.onError {
throw Exception(it.localizedMessage)
throw it
}
}
}
@ -96,7 +97,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
importBookshelfByJson(text, groupId)
}
else -> {
throw Exception("格式不对")
throw NoStackTraceException("格式不对")
}
}
}.onError {

Loading…
Cancel
Save