pull/1336/head
gedoor 4 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 { } 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.RssArticle
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.model.Debug 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.AnalyzeRule
import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
@ -26,7 +27,7 @@ object RssParserByRule {
val sourceUrl = rssSource.sourceUrl val sourceUrl = rssSource.sourceUrl
var nextUrl: String? = null var nextUrl: String? = null
if (body.isNullOrBlank()) { if (body.isNullOrBlank()) {
throw Exception( throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, rssSource.sourceUrl) 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.BookSource
import io.legado.app.data.entities.rule.TocRule import io.legado.app.data.entities.rule.TocRule
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.TocEmptyException import io.legado.app.model.TocEmptyException
import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
@ -30,7 +31,7 @@ object BookChapterList {
baseUrl: String, baseUrl: String,
body: String? body: String?
): List<BookChapter> { ): List<BookChapter> {
body ?: throw Exception( body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
val chapterList = ArrayList<BookChapter>() 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.help.BookHelp
import io.legado.app.model.ContentEmptyException import io.legado.app.model.ContentEmptyException
import io.legado.app.model.Debug 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.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
@ -34,7 +35,7 @@ object BookContent {
body: String?, body: String?,
nextChapterUrl: String? = null nextChapterUrl: String? = null
): String { ): String {
body ?: throw Exception( body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${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.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.Debug 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.AnalyzeRule
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
@ -25,7 +26,7 @@ object BookInfo {
body: String?, body: String?,
canReName: Boolean, canReName: Boolean,
) { ) {
body ?: throw Exception( body ?: throw NoStackTraceException(
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${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.data.entities.rule.BookListRule
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.Debug 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.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
@ -28,7 +29,7 @@ object BookList {
body: String?, body: String?,
isSearch: Boolean = true, isSearch: Boolean = true,
): ArrayList<SearchBook> { ): ArrayList<SearchBook> {
body ?: throw Exception( body ?: throw NoStackTraceException(
appCtx.getString( appCtx.getString(
R.string.error_get_web_content, R.string.error_get_web_content,
analyzeUrl.ruleUrl analyzeUrl.ruleUrl

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

@ -5,6 +5,7 @@ import android.net.Uri
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.localBook.LocalBook import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.isJson import io.legado.app.utils.isJson
import io.legado.app.utils.printOnDebug import io.legado.app.utils.printOnDebug
@ -49,7 +50,7 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica
} }
val book = LocalBook.importFile(uri) val book = LocalBook.importFile(uri)
openBookLiveData.postValue(book.bookUrl) openBookLiveData.postValue(book.bookUrl)
} ?: throw Exception("文件不存在") } ?: throw NoStackTraceException("文件不存在")
} else { } else {
onLineImportLive.postValue(uri) 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.newCall
import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.* import io.legado.app.utils.*
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
@ -114,7 +115,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
mText.isAbsUrl() -> { mText.isAbsUrl() -> {
importSourceUrl(mText) importSourceUrl(mText)
} }
else -> throw Exception(context.getString(R.string.wrong_format)) else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
} }
}.onError { }.onError {
it.printOnDebug() it.printOnDebug()
@ -144,7 +145,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
} }
} }
else -> { 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.newCall
import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.* import io.legado.app.utils.*
class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
@ -111,7 +112,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
mText.isAbsUrl() -> { mText.isAbsUrl() -> {
importSourceUrl(mText) importSourceUrl(mText)
} }
else -> throw Exception(context.getString(R.string.wrong_format)) else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
} }
}.onError { }.onError {
errorLiveData.postValue("ImportError:${it.localizedMessage}") 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.newCall
import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.okHttpClient
import io.legado.app.help.http.text import io.legado.app.help.http.text
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
@ -56,11 +57,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
if (json.isJsonArray()) { if (json.isJsonArray()) {
GSON.fromJsonArray<TxtTocRule>(json)?.let { GSON.fromJsonArray<TxtTocRule>(json)?.let {
appDb.txtTocRuleDao.insert(*it.toTypedArray()) appDb.txtTocRuleDao.insert(*it.toTypedArray())
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} else { } else {
GSON.fromJsonObject<TxtTocRule>(json)?.let { GSON.fromJsonObject<TxtTocRule>(json)?.let {
appDb.txtTocRuleDao.insert(it) appDb.txtTocRuleDao.insert(it)
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} }
}.onSuccess { }.onSuccess {
finally.invoke(context.getString(R.string.success), "导入Txt规则成功") finally.invoke(context.getString(R.string.success), "导入Txt规则成功")
@ -78,12 +79,12 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
GSON.fromJsonArray<HttpTTS>(json)?.let { GSON.fromJsonArray<HttpTTS>(json)?.let {
appDb.httpTTSDao.insert(*it.toTypedArray()) appDb.httpTTSDao.insert(*it.toTypedArray())
return@execute it.size return@execute it.size
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} else { } else {
GSON.fromJsonObject<HttpTTS>(json)?.let { GSON.fromJsonObject<HttpTTS>(json)?.let {
appDb.httpTTSDao.insert(it) appDb.httpTTSDao.insert(it)
return@execute 1 return@execute 1
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} }
}.onSuccess { }.onSuccess {
finally.invoke(context.getString(R.string.success), "导入${it}朗读引擎") finally.invoke(context.getString(R.string.success), "导入${it}朗读引擎")
@ -100,11 +101,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) {
if (json.isJsonArray()) { if (json.isJsonArray()) {
GSON.fromJsonArray<ThemeConfig.Config>(json)?.forEach { GSON.fromJsonArray<ThemeConfig.Config>(json)?.forEach {
ThemeConfig.addConfig(it) ThemeConfig.addConfig(it)
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} else { } else {
GSON.fromJsonObject<ThemeConfig.Config>(json)?.let { GSON.fromJsonObject<ThemeConfig.Config>(json)?.let {
ThemeConfig.addConfig(it) ThemeConfig.addConfig(it)
} ?: throw Exception("格式不对") } ?: throw NoStackTraceException("格式不对")
} }
}.onSuccess { }.onSuccess {
finally.invoke(context.getString(R.string.success), "导入主题成功") 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.BookHelp
import io.legado.app.help.ContentProcessor import io.legado.app.help.ContentProcessor
import io.legado.app.help.storage.AppWebDav import io.legado.app.help.storage.AppWebDav
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.ReadAloud import io.legado.app.model.ReadAloud
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.model.localBook.LocalBook import io.legado.app.model.localBook.LocalBook
@ -199,7 +200,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
WebBook.preciseSearch(this, sources, name, author)?.let { WebBook.preciseSearch(this, sources, name, author)?.let {
it.second.upInfoFromOld(ReadBook.book) it.second.upInfoFromOld(ReadBook.book)
changeTo(it.first, it.second) changeTo(it.first, it.second)
} ?: throw Exception("自动换源失败") } ?: throw NoStackTraceException("自动换源失败")
}.onStart { }.onStart {
ReadBook.upMsg(context.getString(R.string.source_auto_changing)) ReadBook.upMsg(context.getString(R.string.source_auto_changing))
}.onError { }.onError {

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

Loading…
Cancel
Save