pull/1319/head
gedoor 3 years ago
parent f1788ed904
commit ec970564cd
  1. 2
      app/src/main/java/io/legado/app/api/controller/BookController.kt
  2. 22
      app/src/main/java/io/legado/app/constant/AppLog.kt
  3. 5
      app/src/main/java/io/legado/app/data/entities/BaseSource.kt
  4. 2
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  5. 2
      app/src/main/java/io/legado/app/help/BookHelp.kt
  6. 2
      app/src/main/java/io/legado/app/help/BookSourceAnalyzer.kt
  7. 14
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  8. 6
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  9. 2
      app/src/main/java/io/legado/app/help/ThemeConfig.kt
  10. 3
      app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt
  11. 9
      app/src/main/java/io/legado/app/help/http/SSLHelper.kt
  12. 21
      app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt
  13. 7
      app/src/main/java/io/legado/app/help/storage/Preferences.kt
  14. 10
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  15. 5
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  16. 7
      app/src/main/java/io/legado/app/model/CacheBook.kt
  17. 3
      app/src/main/java/io/legado/app/model/ReadBook.kt
  18. 3
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt
  19. 3
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt
  20. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  21. 11
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  22. 7
      app/src/main/java/io/legado/app/model/localBook/UmdFile.kt
  23. 8
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  24. 2
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  25. 2
      app/src/main/java/io/legado/app/service/WebService.kt
  26. 3
      app/src/main/java/io/legado/app/service/WebTileService.kt
  27. 41
      app/src/main/java/io/legado/app/ui/about/AppLogDialog.kt
  28. 7
      app/src/main/java/io/legado/app/ui/about/DonateFragment.kt
  29. 3
      app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt
  30. 2
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  31. 6
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  32. 4
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  33. 5
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt
  34. 3
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowViewModel.kt
  35. 2
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt
  36. 6
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  37. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt
  38. 5
      app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt
  39. 2
      app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt
  40. 3
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  41. 5
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt
  42. 2
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt
  43. 3
      app/src/main/java/io/legado/app/ui/widget/SearchView.kt
  44. 3
      app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/Utils.kt
  45. 2
      app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt
  46. 3
      app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt
  47. 28
      app/src/main/java/io/legado/app/utils/ACache.kt
  48. 4
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt
  49. 2
      app/src/main/java/io/legado/app/utils/DocumentUtils.kt
  50. 4
      app/src/main/java/io/legado/app/utils/FileUtils.kt
  51. 19
      app/src/main/java/io/legado/app/utils/LogUtils.kt
  52. 2
      app/src/main/java/io/legado/app/utils/MD5Utils.kt
  53. 6
      app/src/main/java/io/legado/app/utils/NetworkUtils.kt
  54. 4
      app/src/main/java/io/legado/app/utils/RealPathUtil.kt
  55. 2
      app/src/main/java/io/legado/app/utils/StringUtils.kt
  56. 2
      app/src/main/java/io/legado/app/utils/SystemUtils.kt
  57. 4
      app/src/main/java/io/legado/app/utils/UriExtensions.kt
  58. 2
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt
  59. 2
      app/src/main/java/io/legado/app/utils/ZipUtils.kt
  60. 7
      app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt
  61. 5
      epublib/src/main/java/me/ag2s/epublib/epub/PackageDocumentWriter.java

@ -216,7 +216,7 @@ object BookController {
if (book.isUmd()) UmdFile.upBookInfo(book) if (book.isUmd()) UmdFile.upBookInfo(book)
appDb.bookDao.insert(book) appDb.bookDao.insert(book)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
return returnData.setErrorMsg( return returnData.setErrorMsg(
e.localizedMessage ?: appCtx.getString(R.string.unknown_error) e.localizedMessage ?: appCtx.getString(R.string.unknown_error)
) )

@ -1,24 +1,16 @@
package io.legado.app.constant package io.legado.app.constant
import android.annotation.SuppressLint
import java.text.SimpleDateFormat
import java.util.*
object AppLog { object AppLog {
@SuppressLint("ConstantLocale") val logs = arrayListOf<Triple<Long, String, Throwable?>>()
private val logTimeFormat = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault())
val logs = arrayListOf<String>()
fun addLog(log: String?) { @Synchronized
log ?: return fun addLog(message: String?, throwable: Throwable?) {
synchronized(logs) { message ?: return
if (logs.size > 1000) { if (logs.size > 1000) {
logs.removeLastOrNull() logs.removeLastOrNull()
}
logs.add(0, logTimeFormat.format(Date()) + " " + log)
} }
logs.add(0, Triple(System.currentTimeMillis(), message, throwable))
} }
} }

@ -10,6 +10,7 @@ import io.legado.app.help.http.CookieStore
import io.legado.app.utils.EncoderUtils import io.legado.app.utils.EncoderUtils
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
import io.legado.app.utils.printOnDebug
import javax.script.SimpleBindings import javax.script.SimpleBindings
/** /**
@ -95,7 +96,7 @@ interface BaseSource : JsExtensions {
?: return null ?: return null
return String(decodeBytes) return String(decodeBytes)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
return null return null
} }
} }
@ -115,7 +116,7 @@ interface BaseSource : JsExtensions {
CacheManager.put("userInfo_${getStoreUrl()}", encodeStr) CacheManager.put("userInfo_${getStoreUrl()}", encodeStr)
true true
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
false false
} }
} }

@ -91,7 +91,7 @@ data class BookSource(
} }
} }
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
kinds.add(ExploreKind(it.localizedMessage ?: "")) kinds.add(ExploreKind(it.localizedMessage ?: ""))
} }
} }

@ -126,7 +126,7 @@ object BookHelp {
).writeBytes(it) ).writeBytes(it)
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
downloadImages.remove(src) downloadImages.remove(src)
} }

@ -140,7 +140,7 @@ object BookSourceAnalyzer {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return source return source
} }

@ -45,7 +45,7 @@ interface JsExtensions {
val analyzeUrl = AnalyzeUrl(urlStr, source = getSource()) val analyzeUrl = AnalyzeUrl(urlStr, source = getSource())
analyzeUrl.getStrResponse().body analyzeUrl.getStrResponse().body
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
}.getOrElse { }.getOrElse {
it.msg it.msg
} }
@ -80,7 +80,7 @@ interface JsExtensions {
kotlin.runCatching { kotlin.runCatching {
analyzeUrl.getStrResponse() analyzeUrl.getStrResponse()
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -94,7 +94,7 @@ interface JsExtensions {
kotlin.runCatching { kotlin.runCatching {
analyzeUrl.getStrResponse() analyzeUrl.getStrResponse()
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -480,7 +480,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printOnDebug()
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -519,7 +519,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -557,7 +557,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
log(e.localizedMessage ?: "aesEncodeToByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToByteArrayERROR")
null null
} }
@ -594,7 +594,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR")
null null
} }

@ -61,7 +61,7 @@ object ReadBookConfig {
val json = configFile.readText() val json = configFile.readText()
configs = GSON.fromJsonArray(json) configs = GSON.fromJsonArray(json)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
(configs ?: DefaultData.readConfigs).let { (configs ?: DefaultData.readConfigs).let {
@ -78,7 +78,7 @@ object ReadBookConfig {
val json = configFile.readText() val json = configFile.readText()
c = GSON.fromJsonObject(json) c = GSON.fromJsonObject(json)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
shareConfig = c ?: configList.getOrNull(5) ?: Config() shareConfig = c ?: configList.getOrNull(5) ?: Config()
@ -570,7 +570,7 @@ object ReadBookConfig {
) )
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return bgDrawable ?: ColorDrawable(appCtx.getCompatColor(R.color.background)) return bgDrawable ?: ColorDrawable(appCtx.getCompatColor(R.color.background))
} }

@ -108,7 +108,7 @@ object ThemeConfig {
val json = configFile.readText() val json = configFile.readText()
return GSON.fromJsonArray(json) return GSON.fromJsonArray(json)
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
} }
} }
return null return null

@ -1,6 +1,7 @@
package io.legado.app.help.coroutine package io.legado.app.help.coroutine
import io.legado.app.BuildConfig import io.legado.app.BuildConfig
import io.legado.app.utils.printOnDebug
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@ -143,7 +144,7 @@ class Coroutine<T>(
} }
} catch (e: Throwable) { } catch (e: Throwable) {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
e.printStackTrace() e.printOnDebug()
} }
val consume: Boolean = errorReturn?.value?.let { value -> val consume: Boolean = errorReturn?.value?.let { value ->
if (isActive) { if (isActive) {

@ -1,6 +1,7 @@
package io.legado.app.help.http package io.legado.app.help.http
import android.annotation.SuppressLint import android.annotation.SuppressLint
import io.legado.app.utils.printOnDebug
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.security.KeyManagementException import java.security.KeyManagementException
@ -125,9 +126,9 @@ object SSLHelper {
sslParams.trustManager = manager sslParams.trustManager = manager
return sslParams return sslParams
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
e.printStackTrace() e.printOnDebug()
} catch (e: KeyManagementException) { } catch (e: KeyManagementException) {
e.printStackTrace() e.printOnDebug()
} }
return null return null
} }
@ -141,7 +142,7 @@ object SSLHelper {
kmf.init(clientKeyStore, password.toCharArray()) kmf.init(clientKeyStore, password.toCharArray())
return kmf.keyManagers return kmf.keyManagers
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return null return null
} }
@ -160,7 +161,7 @@ object SSLHelper {
try { try {
certStream.close() certStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
} }
//我们创建一个默认类型的TrustManagerFactory //我们创建一个默认类型的TrustManagerFactory

@ -10,6 +10,7 @@ import com.google.android.gms.net.CronetProviderInstaller
import io.legado.app.BuildConfig import io.legado.app.BuildConfig
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.utils.printOnDebug
import org.chromium.net.CronetEngine import org.chromium.net.CronetEngine
import org.json.JSONObject import org.json.JSONObject
import splitties.init.appCtx import splitties.init.appCtx
@ -163,7 +164,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
abiField.isAccessible = true abiField.isAccessible = true
cpuAbi = abiField.get(appInfo) as String? cpuAbi = abiField.get(appInfo) as String?
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
if (TextUtils.isEmpty(cpuAbi)) { if (TextUtils.isEmpty(cpuAbi)) {
cpuAbi = Build.SUPPORTED_ABIS[0] cpuAbi = Build.SUPPORTED_ABIS[0]
@ -214,7 +215,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
} }
return true return true
} catch (e: Throwable) { } catch (e: Throwable) {
e.printStackTrace() e.printOnDebug()
if (destFile.exists() && !destFile.delete()) { if (destFile.exists() && !destFile.delete()) {
destFile.deleteOnExit() destFile.deleteOnExit()
} }
@ -223,14 +224,14 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
try { try {
inputStream.close() inputStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
} }
if (outputStream != null) { if (outputStream != null) {
try { try {
outputStream.close() outputStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }
@ -303,20 +304,20 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
} }
return true return true
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
if (fileInputStream != null) { if (fileInputStream != null) {
try { try {
fileInputStream.close() fileInputStream.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
if (os != null) { if (os != null) {
try { try {
os.close() os.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }
@ -338,15 +339,15 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
} }
return String.format("%032x", BigInteger(1, md5.digest())).lowercase() return String.format("%032x", BigInteger(1, md5.digest())).lowercase()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
if (fileInputStream != null) { if (fileInputStream != null) {
try { try {
fileInputStream.close() fileInputStream.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.content.ContextWrapper import android.content.ContextWrapper
import android.content.SharedPreferences import android.content.SharedPreferences
import io.legado.app.utils.printOnDebug
import java.io.File import java.io.File
object Preferences { object Preferences {
@ -36,11 +37,11 @@ object Preferences {
// 返回修改路径以后的 SharedPreferences :%FILE_PATH%/%fileName%.xml // 返回修改路径以后的 SharedPreferences :%FILE_PATH%/%fileName%.xml
return context.getSharedPreferences(fileName, Activity.MODE_PRIVATE) return context.getSharedPreferences(fileName, Activity.MODE_PRIVATE)
} catch (e: NoSuchFieldException) { } catch (e: NoSuchFieldException) {
e.printStackTrace() e.printOnDebug()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
e.printStackTrace() e.printOnDebug()
} catch (e: IllegalAccessException) { } catch (e: IllegalAccessException) {
e.printStackTrace() e.printOnDebug()
} }
return null return null
} }

@ -94,7 +94,7 @@ object Restore {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }
@ -169,7 +169,7 @@ object Restore {
ThemeConfig.upConfig() ThemeConfig.upConfig()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
if (!ignoreReadConfig) { if (!ignoreReadConfig) {
try { try {
@ -181,7 +181,7 @@ object Restore {
ReadBookConfig.initConfigs() ReadBookConfig.initConfigs()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
try { try {
val file = val file =
@ -192,7 +192,7 @@ object Restore {
ReadBookConfig.initShareConfig() ReadBookConfig.initShareConfig()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
Preferences.getSharedPreferences(appCtx, path, "config")?.all?.let { map -> Preferences.getSharedPreferences(appCtx, path, "config")?.all?.let { map ->
@ -267,7 +267,7 @@ object Restore {
val json = file.readText() val json = file.readText()
return GSON.fromJsonArray(json) return GSON.fromJsonArray(json)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return null return null
} }

@ -3,6 +3,7 @@ package io.legado.app.lib.webdav
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.utils.printOnDebug
import okhttp3.* import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.RequestBody.Companion.asRequestBody
@ -101,7 +102,7 @@ class WebDav(urlStr: String) {
method("PROPFIND", requestBody) method("PROPFIND", requestBody)
}.text() }.text()
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
}.getOrNull() }.getOrNull()
} }
return null return null
@ -133,7 +134,7 @@ class WebDav(urlStr: String) {
} }
list.add(webDavFile) list.add(webDavFile)
} catch (e: MalformedURLException) { } catch (e: MalformedURLException) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }

@ -12,6 +12,7 @@ import io.legado.app.help.BookHelp
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.service.CacheBookService import io.legado.app.service.CacheBookService
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.startService import io.legado.app.utils.startService
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@ -169,7 +170,11 @@ class CacheBook(var bookSource: BookSource, var book: Book) {
if (errorDownloadMap[index] ?: 0 < 3) { if (errorDownloadMap[index] ?: 0 < 3) {
waitDownloadSet.add(index) waitDownloadSet.add(index)
} else { } else {
AppLog.addLog("${book.name}-${chapterTitle} ${error.localizedMessage}") AppLog.addLog(
"download ${book.name}-${chapterTitle} error:${error.localizedMessage}",
error
)
error.printOnDebug()
} }
} }

@ -14,6 +14,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.ui.book.read.page.provider.ImageProvider
import io.legado.app.utils.msg import io.legado.app.utils.msg
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
@ -365,7 +366,7 @@ object ReadBook : CoroutineScope by MainScope() {
} }
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}") appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}")
}.onSuccess { }.onSuccess {
success?.invoke() success?.invoke()

@ -3,6 +3,7 @@ package io.legado.app.model.analyzeRule
import androidx.annotation.Keep import androidx.annotation.Keep
import com.jayway.jsonpath.JsonPath import com.jayway.jsonpath.JsonPath
import com.jayway.jsonpath.ReadContext import com.jayway.jsonpath.ReadContext
import io.legado.app.utils.printOnDebug
import java.util.* import java.util.*
@Suppress("RegExpRedundantEscape") @Suppress("RegExpRedundantEscape")
@ -155,7 +156,7 @@ class AnalyzeByJSonPath(json: Any) {
try { try {
return it.read<ArrayList<Any>>(rules[0]) return it.read<ArrayList<Any>>(rules[0])
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
return null return null

@ -1,6 +1,7 @@
package io.legado.app.model.analyzeRule package io.legado.app.model.analyzeRule
import androidx.annotation.Keep import androidx.annotation.Keep
import io.legado.app.utils.printOnDebug
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.select.Collector import org.jsoup.select.Collector
@ -254,7 +255,7 @@ class AnalyzeByJSoup(doc: Any) {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return textS return textS

@ -653,7 +653,7 @@ class AnalyzeRule(
val analyzeUrl = AnalyzeUrl(urlStr, book = book, source = source) val analyzeUrl = AnalyzeUrl(urlStr, book = book, source = source)
analyzeUrl.getStrResponse().body analyzeUrl.getStrResponse().body
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
}.getOrElse { }.getOrElse {
it.msg it.msg
} }

@ -6,10 +6,7 @@ import android.text.TextUtils
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.utils.FileUtils import io.legado.app.utils.*
import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.MD5Utils
import io.legado.app.utils.externalFiles
import me.ag2s.epublib.domain.EpubBook import me.ag2s.epublib.domain.EpubBook
import me.ag2s.epublib.epub.EpubReader import me.ag2s.epublib.epub.EpubReader
import org.jsoup.Jsoup import org.jsoup.Jsoup
@ -97,7 +94,7 @@ class EpubFile(var book: Book) {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -111,7 +108,7 @@ class EpubFile(var book: Book) {
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return null return null
} }
@ -208,7 +205,7 @@ class EpubFile(var book: Book) {
title = elements[0].text() title = elements[0].text()
} }
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
} }
val chapter = BookChapter() val chapter = BookChapter()

@ -4,10 +4,7 @@ import android.net.Uri
import android.util.Log import android.util.Log
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.utils.FileUtils import io.legado.app.utils.*
import io.legado.app.utils.MD5Utils
import io.legado.app.utils.externalFiles
import io.legado.app.utils.isContentScheme
import me.ag2s.umdlib.domain.UmdBook import me.ag2s.umdlib.domain.UmdBook
import me.ag2s.umdlib.umd.UmdReader import me.ag2s.umdlib.umd.UmdReader
import splitties.init.appCtx import splitties.init.appCtx
@ -82,7 +79,7 @@ class UmdFile(var book: Book) {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }

@ -137,7 +137,7 @@ class AudioPlayService : BaseService(),
exoPlayer.playWhenReady = true exoPlayer.playWhenReady = true
exoPlayer.prepare() exoPlayer.prepare()
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
toastOnUi("$url ${it.localizedMessage}") toastOnUi("$url ${it.localizedMessage}")
stopSelf() stopSelf()
} }
@ -158,7 +158,7 @@ class AudioPlayService : BaseService(),
postEvent(EventBus.AUDIO_STATE, Status.PAUSE) postEvent(EventBus.AUDIO_STATE, Status.PAUSE)
upNotification() upNotification()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -177,7 +177,7 @@ class AudioPlayService : BaseService(),
postEvent(EventBus.AUDIO_STATE, Status.PLAY) postEvent(EventBus.AUDIO_STATE, Status.PLAY)
upNotification() upNotification()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
stopSelf() stopSelf()
} }
} }
@ -246,7 +246,7 @@ class AudioPlayService : BaseService(),
super.onPlayerError(error) super.onPlayerError(error)
AudioPlay.status = Status.STOP AudioPlay.status = Status.STOP
postEvent(EventBus.AUDIO_STATE, Status.STOP) postEvent(EventBus.AUDIO_STATE, Status.STOP)
error.printStackTrace() error.printOnDebug()
} }
override fun onPlayerErrorChanged(error: PlaybackException?) { override fun onPlayerErrorChanged(error: PlaybackException?) {

@ -148,7 +148,7 @@ class HttpReadAloudService : BaseReadAloudService(),
playingIndex = nowSpeak playingIndex = nowSpeak
postEvent(EventBus.TTS_PROGRESS, readAloudNumber + 1) postEvent(EventBus.TTS_PROGRESS, readAloudNumber + 1)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }

@ -86,7 +86,7 @@ class WebService : BaseService() {
upNotification() upNotification()
} catch (e: IOException) { } catch (e: IOException) {
toastOnUi(e.localizedMessage ?: "") toastOnUi(e.localizedMessage ?: "")
e.printStackTrace() e.printOnDebug()
stopSelf() stopSelf()
} }
} else { } else {

@ -7,6 +7,7 @@ import android.service.quicksettings.Tile
import android.service.quicksettings.TileService import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import io.legado.app.constant.IntentAction import io.legado.app.constant.IntentAction
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.startService import io.legado.app.utils.startService
/** /**
@ -44,7 +45,7 @@ class WebTileService : TileService() {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }

@ -0,0 +1,41 @@
package io.legado.app.ui.about
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.utils.windowSize
class AppLogDialog : BaseDialogFragment() {
companion object {
fun show(fragmentManager: FragmentManager) {
AppLogDialog().show(fragmentManager, "appLogDialog")
}
}
override fun onStart() {
super.onStart()
val dm = requireActivity().windowSize
dialog?.window?.setLayout(
(dm.widthPixels * 0.9).toInt(),
ViewGroup.LayoutParams.WRAP_CONTENT
)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.dialog_book_group_edit, container)
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
}
}

@ -7,10 +7,7 @@ import android.view.View
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.ACache import io.legado.app.utils.*
import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.openUrl
import io.legado.app.utils.sendToClip
class DonateFragment : PreferenceFragmentCompat() { class DonateFragment : PreferenceFragmentCompat() {
@ -49,7 +46,7 @@ class DonateFragment : PreferenceFragmentCompat() {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent) context.startActivity(intent)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
ACache.get(requireContext(), cacheDir = false) ACache.get(requireContext(), cacheDir = false)
.put("proTime", System.currentTimeMillis()) .put("proTime", System.currentTimeMillis())

@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
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.readText import io.legado.app.utils.readText
import java.io.File import java.io.File
@ -53,7 +54,7 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica
onLineImportLive.postValue(uri) onLineImportLive.postValue(uri)
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
} }
} }

@ -117,7 +117,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
else -> throw Exception(context.getString(R.string.wrong_format)) else -> throw Exception(context.getString(R.string.wrong_format))
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
errorLiveData.postValue(it.localizedMessage ?: "") errorLiveData.postValue(it.localizedMessage ?: "")
}.onSuccess { }.onSuccess {
comparisonSource() comparisonSource()

@ -11,7 +11,6 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.AppConst.charsets import io.legado.app.constant.AppConst.charsets
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb import io.legado.app.data.appDb
@ -26,8 +25,8 @@ import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.selector import io.legado.app.lib.dialogs.selector
import io.legado.app.model.CacheBook import io.legado.app.model.CacheBook
import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.widget.dialog.TextListDialog
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -136,8 +135,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
R.id.menu_export_file_name -> alertExportFileName() R.id.menu_export_file_name -> alertExportFileName()
R.id.menu_export_type -> showExportTypeConfig() R.id.menu_export_type -> showExportTypeConfig()
R.id.menu_export_charset -> showCharsetConfig() R.id.menu_export_charset -> showCharsetConfig()
R.id.menu_log -> R.id.menu_log -> AppLogDialog.show(supportFragmentManager)
TextListDialog.show(supportFragmentManager, getString(R.string.log), AppLog.logs)
else -> if (item.groupId == R.id.menu_group) { else -> if (item.groupId == R.id.menu_group) {
binding.titleBar.subtitle = item.title binding.titleBar.subtitle = item.title
groupId = appDb.bookGroupDao.getByName(item.title.toString())?.groupId ?: 0 groupId = appDb.bookGroupDao.getByName(item.title.toString())?.groupId ?: 0

@ -56,7 +56,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
} }
}.onError { }.onError {
finally(it.localizedMessage ?: "ERROR") finally(it.localizedMessage ?: "ERROR")
it.printStackTrace() it.printOnDebug()
}.onSuccess { }.onSuccess {
finally(context.getString(R.string.success)) finally(context.getString(R.string.success))
} }
@ -187,7 +187,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
} }
}.onError { }.onError {
finally(it.localizedMessage ?: "ERROR") finally(it.localizedMessage ?: "ERROR")
it.printStackTrace() it.printOnDebug()
}.onSuccess { }.onSuccess {
finally(context.getString(R.string.success)) finally(context.getString(R.string.success))
} }

@ -17,6 +17,7 @@ import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefString import io.legado.app.utils.getPrefString
import io.legado.app.utils.printOnDebug
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import splitties.init.appCtx import splitties.init.appCtx
@ -184,7 +185,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook) searchFinish(searchBook)
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
} }
} }
@ -197,7 +198,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook) searchFinish(searchBook)
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
} }
} }

@ -10,6 +10,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchBook
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.msg import io.legado.app.utils.msg
import io.legado.app.utils.printOnDebug
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
class ExploreShowViewModel(application: Application) : BaseViewModel(application) { class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
@ -42,7 +43,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
appDb.searchBookDao.insert(*searchBooks.toTypedArray()) appDb.searchBookDao.insert(*searchBooks.toTypedArray())
page++ page++
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
errorLiveData.postValue(it.msg) errorLiveData.postValue(it.msg)
} }
} }

@ -149,7 +149,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
} }
context.startActivity(intent) context.startActivity(intent)
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
context.toastOnUi(it.localizedMessage ?: "ERROR") context.toastOnUi(it.localizedMessage ?: "ERROR")
} }
} }

@ -282,7 +282,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
}.onSuccess { }.onSuccess {
toastOnUi("导出成功, 文件名为 $exportFileName") toastOnUi("导出成功, 文件名为 $exportFileName")
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
longToast("导出失败:${it.localizedMessage}") longToast("导出失败:${it.localizedMessage}")
} }
} }
@ -319,7 +319,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
importConfig(uri.readBytes(requireContext())!!) importConfig(uri.readBytes(requireContext())!!)
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
longToast("导入失败:${it.localizedMessage}") longToast("导入失败:${it.localizedMessage}")
} }
} }
@ -333,7 +333,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
toastOnUi("导入成功") toastOnUi("导入成功")
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
longToast("导入失败:${it.localizedMessage}") longToast("导入失败:${it.localizedMessage}")
} }
} }

@ -47,7 +47,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
success?.invoke() success?.invoke()
}.onError { }.onError {
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
it.printStackTrace() it.printOnDebug()
} }
} }
@ -61,7 +61,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
} }
}.onError { }.onError {
context.toastOnUi(it.localizedMessage ?: "Error") context.toastOnUi(it.localizedMessage ?: "Error")
it.printStackTrace() it.printOnDebug()
} }
} }

@ -8,6 +8,7 @@ import io.legado.app.base.BaseViewModel
import io.legado.app.help.DirectLinkUpload import io.legado.app.help.DirectLinkUpload
import io.legado.app.utils.FileUtils import io.legado.app.utils.FileUtils
import io.legado.app.utils.isContentScheme import io.legado.app.utils.isContentScheme
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.writeBytes import io.legado.app.utils.writeBytes
import java.io.File import java.io.File
@ -26,7 +27,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application)
}.onSuccess { }.onSuccess {
success.invoke(it) success.invoke(it)
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
} }
} }
@ -46,7 +47,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application)
Uri.fromFile(newFile) Uri.fromFile(newFile)
} }
}.onError { }.onError {
it.printStackTrace() it.printOnDebug()
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
}.onSuccess { }.onSuccess {
success.invoke(it) success.invoke(it)

@ -129,7 +129,7 @@ class RuleUiLoginDialog : BaseDialogFragment() {
dismiss() dismiss()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
toastOnUi("error:${e.localizedMessage}") toastOnUi("error:${e.localizedMessage}")
} }
} }

@ -13,6 +13,7 @@ import io.legado.app.help.LocalConfig
import io.legado.app.model.CacheBook import io.legado.app.model.CacheBook
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import io.legado.app.utils.printOnDebug
import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.asCoroutineDispatcher
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CopyOnWriteArraySet
@ -89,7 +90,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
) )
CacheBook.start(context, book.bookUrl, book.durChapterIndex, endIndex) CacheBook.start(context, book.bookUrl, book.durChapterIndex, endIndex)
}.onError(upTocPool) { }.onError(upTocPool) {
it.printStackTrace() it.printOnDebug()
}.onFinally(upTocPool) { }.onFinally(upTocPool) {
synchronized(this) { synchronized(this) {
bookMap.remove(bookEntry.key) bookMap.remove(bookEntry.key)

@ -9,6 +9,7 @@ import io.legado.app.data.appDb
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.rss.Rss import io.legado.app.model.rss.Rss
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -52,7 +53,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
} }
}.onError { }.onError {
loadFinally.postValue(false) loadFinally.postValue(false)
it.printStackTrace() it.printOnDebug()
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
} }
} }
@ -68,7 +69,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
loadMoreSuccess(it.first) loadMoreSuccess(it.first)
} }
.onError { .onError {
it.printStackTrace() it.printOnDebug()
loadFinally.postValue(false) loadFinally.postValue(false)
} }
} else { } else {

@ -38,7 +38,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
success() success()
}.onError { }.onError {
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
it.printStackTrace() it.printOnDebug()
} }
} }

@ -15,6 +15,7 @@ import android.view.Gravity
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.printOnDebug
class SearchView @JvmOverloads constructor( class SearchView @JvmOverloads constructor(
context: Context, context: Context,
@ -42,7 +43,7 @@ class SearchView @JvmOverloads constructor(
textView!!.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f) textView!!.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
textView!!.gravity = Gravity.CENTER_VERTICAL textView!!.gravity = Gravity.CENTER_VERTICAL
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }

@ -22,6 +22,7 @@ import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import io.legado.app.utils.printOnDebug
import kotlin.math.roundToInt import kotlin.math.roundToInt
object Utils { object Utils {
@ -65,7 +66,7 @@ object Utils {
try { try {
return Bitmap.createBitmap(width, height, config) return Bitmap.createBitmap(width, height, config)
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
e.printStackTrace() e.printOnDebug()
if (retryCount > 0) { if (retryCount > 0) {
System.gc() System.gc()
return createBitmapSafely(width, height, config, retryCount - 1) return createBitmapSafely(width, height, config, retryCount - 1)

@ -41,7 +41,7 @@ class FontAdapter(context: Context, val callBack: CallBack) :
} }
tvFont.typeface = typeface tvFont.typeface = typeface
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}") context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}")
} }
tvFont.text = item.name tvFont.text = item.name

@ -20,6 +20,7 @@ import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.sp import io.legado.app.utils.sp
import kotlin.math.min import kotlin.math.min
import kotlin.math.pow import kotlin.math.pow
@ -316,7 +317,7 @@ class CircleImageView @JvmOverloads constructor(
drawable.draw(canvas) drawable.draw(canvas)
bitmap bitmap
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
null null
} }

@ -74,7 +74,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
mCache = ACacheManager(cacheDir, max_size, max_count) mCache = ACacheManager(cacheDir, max_size, max_count)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -96,7 +96,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
file.writeText(value) file.writeText(value)
mCache.put(file) mCache.put(file)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
} }
@ -131,7 +131,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
removeFile = true removeFile = true
} }
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
if (removeFile) if (removeFile)
remove(key) remove(key)
@ -269,7 +269,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
null null
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
if (removeFile) if (removeFile)
remove(key) remove(key)
@ -299,7 +299,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -318,18 +318,18 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
ois = ObjectInputStream(bis) ois = ObjectInputStream(bis)
return ois.readObject() return ois.readObject()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
try { try {
bis?.close() bis?.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
try { try {
ois?.close() ois?.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -427,7 +427,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
return f return f
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
return null return null
@ -488,7 +488,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return false return false
@ -662,7 +662,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
cacheCount.set(count) cacheCount.set(count)
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
@ -693,7 +693,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
file.setLastModified(currentTime) file.setLastModified(currentTime)
lastUsageDates[file] = currentTime lastUsageDates[file] = currentTime
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -727,7 +727,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
} }
@ -767,7 +767,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
return fileSize return fileSize
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
return 0 return 0
} }

@ -157,7 +157,7 @@ val Context.sysScreenOffTime: Int
screenOffTime = screenOffTime =
Settings.System.getInt(contentResolver, Settings.System.SCREEN_OFF_TIMEOUT) Settings.System.getInt(contentResolver, Settings.System.SCREEN_OFF_TIMEOUT)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return screenOffTime return screenOffTime
} }
@ -299,7 +299,7 @@ val Context.channel: String
val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA) val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
return appInfo.metaData.getString("channel") ?: "" return appInfo.metaData.getString("channel") ?: ""
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return "" return ""
} }

@ -130,7 +130,7 @@ object DocumentUtils {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} finally { } finally {
c?.close() c?.close()
} }

@ -50,7 +50,7 @@ object FileUtils {
file.createNewFile() file.createNewFile()
} }
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
} }
return file return file
} }
@ -113,7 +113,7 @@ object FileUtils {
try { try {
sdCardDirectory = File(sdCardDirectory).canonicalPath sdCardDirectory = File(sdCardDirectory).canonicalPath
} catch (ioe: IOException) { } catch (ioe: IOException) {
ioe.printStackTrace() ioe.printOnDebug()
} }
return sdCardDirectory return sdCardDirectory
} }

@ -1,6 +1,9 @@
@file:Suppress("unused")
package io.legado.app.utils package io.legado.app.utils
import android.annotation.SuppressLint import android.annotation.SuppressLint
import io.legado.app.BuildConfig
import splitties.init.appCtx import splitties.init.appCtx
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -8,7 +11,7 @@ import java.util.logging.*
@Suppress("unused") @Suppress("unused")
object LogUtils { object LogUtils {
const val TIME_PATTERN = "yyyy-MM-dd HH:mm:ss" const val TIME_PATTERN = "yy-MM-dd HH:mm:ss.SSS"
@JvmStatic @JvmStatic
fun d(tag: String, msg: String) { fun d(tag: String, msg: String) {
@ -65,3 +68,17 @@ object LogUtils {
return sdf.format(date) return sdf.format(date)
} }
} }
fun Throwable.printOnDebug() {
if (BuildConfig.DEBUG) {
printStackTrace()
}
}
fun dLog(tag: String, msg: String) {
LogUtils.d(tag, msg)
}
fun eLog(tag: String, msg: String) {
LogUtils.e(tag, msg)
}

@ -25,7 +25,7 @@ object MD5Utils {
} }
reStr = stringBuffer.toString() reStr = stringBuffer.toString()
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
e.printStackTrace() e.printOnDebug()
} }
return reStr return reStr

@ -114,7 +114,7 @@ object NetworkUtils {
relativeUrl = parseUrl.toString() relativeUrl = parseUrl.toString()
return relativeUrl return relativeUrl
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return relativeUrl return relativeUrl
} }
@ -130,7 +130,7 @@ object NetworkUtils {
relativeUrl = parseUrl.toString() relativeUrl = parseUrl.toString()
return relativeUrl return relativeUrl
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
} }
return relativeUrl return relativeUrl
} }
@ -158,7 +158,7 @@ object NetworkUtils {
try { try {
enumeration = NetworkInterface.getNetworkInterfaces() enumeration = NetworkInterface.getNetworkInterfaces()
} catch (e: SocketException) { } catch (e: SocketException) {
e.printStackTrace() e.printOnDebug()
} }
if (enumeration != null) { if (enumeration != null) {

@ -111,7 +111,7 @@ object RealPathUtil {
return cursor.getString(index) return cursor.getString(index)
} }
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
e.printStackTrace() e.printOnDebug()
val file = File(context.cacheDir, "tmp") val file = File(context.cacheDir, "tmp")
val filePath = file.absolutePath val filePath = file.absolutePath
var input: FileInputStream? = null var input: FileInputStream? = null
@ -130,7 +130,7 @@ object RealPathUtil {
} }
return File(filePath).absolutePath return File(filePath).absolutePath
} catch (ignored: IOException) { } catch (ignored: IOException) {
ignored.printStackTrace() ignored.printOnDebug()
} finally { } finally {
input?.close() input?.close()
output?.close() output?.close()

@ -95,7 +95,7 @@ object StringUtils {
} }
} }
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
} }
return "" return ""

@ -21,7 +21,7 @@ object SystemUtils {
Settings.System.SCREEN_OFF_TIMEOUT Settings.System.SCREEN_OFF_TIMEOUT
) )
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
} }
return screenOffTime return screenOffTime

@ -41,7 +41,7 @@ fun AppCompatActivity.readUri(uri: Uri?, success: (name: String, bytes: ByteArra
.request() .request()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
toastOnUi(e.localizedMessage ?: "read uri error") toastOnUi(e.localizedMessage ?: "read uri error")
} }
} }
@ -75,7 +75,7 @@ fun Fragment.readUri(uri: Uri?, success: (name: String, bytes: ByteArray) -> Uni
.request() .request()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printOnDebug()
toastOnUi(e.localizedMessage ?: "read uri error") toastOnUi(e.localizedMessage ?: "read uri error")
} }
} }

@ -110,6 +110,6 @@ fun PopupMenu.show(x: Int, y: Int) {
field.isAccessible = true field.isAccessible = true
(field.get(this) as MenuPopupHelper).show(x, y) (field.get(this) as MenuPopupHelper).show(x, y)
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
} }
} }

@ -369,7 +369,7 @@ object ZipUtils {
return try { return try {
file.createNewFile() file.createNewFile()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printOnDebug()
false false
} }
} }

@ -6,10 +6,7 @@ import fi.iki.elonen.NanoWSD
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.utils.GSON import io.legado.app.utils.*
import io.legado.app.utils.fromJsonObject
import io.legado.app.utils.isJson
import io.legado.app.utils.runOnIO
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import splitties.init.appCtx import splitties.init.appCtx
@ -89,7 +86,7 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) :
close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false)
} }
}.onFailure { }.onFailure {
it.printStackTrace() it.printOnDebug()
} }
} }
} }

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import me.ag2s.epublib.BuildConfig;
import me.ag2s.epublib.Constants; import me.ag2s.epublib.Constants;
import me.ag2s.epublib.domain.EpubBook; import me.ag2s.epublib.domain.EpubBook;
import me.ag2s.epublib.domain.Guide; import me.ag2s.epublib.domain.Guide;
@ -51,7 +52,9 @@ public class PackageDocumentWriter extends PackageDocumentBase {
serializer.endDocument(); serializer.endDocument();
serializer.flush(); serializer.flush();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); if (BuildConfig.DEBUG) {
e.printStackTrace();
}
} }
} }

Loading…
Cancel
Save