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

@ -20,6 +20,7 @@ import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
object BookController { object BookController {
@ -209,7 +210,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.printOnDebug() Timber.e(e)
return returnData.setErrorMsg( return returnData.setErrorMsg(
e.localizedMessage ?: appCtx.getString(R.string.unknown_error) e.localizedMessage ?: appCtx.getString(R.string.unknown_error)
) )

@ -7,7 +7,11 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.CacheManager import io.legado.app.help.CacheManager
import io.legado.app.help.JsExtensions import io.legado.app.help.JsExtensions
import io.legado.app.help.http.CookieStore import io.legado.app.help.http.CookieStore
import io.legado.app.utils.* import io.legado.app.utils.EncoderUtils
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.fromJsonObject
import timber.log.Timber
import javax.script.SimpleBindings import javax.script.SimpleBindings
/** /**
@ -107,7 +111,7 @@ interface BaseSource : JsExtensions {
?: return null ?: return null
return String(decodeBytes) return String(decodeBytes)
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
return null return null
} }
} }
@ -127,7 +131,7 @@ interface BaseSource : JsExtensions {
CacheManager.put("userInfo_${getKey()}", encodeStr) CacheManager.put("userInfo_${getKey()}", encodeStr)
true true
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
false false
} }
} }

@ -9,6 +9,7 @@ import io.legado.app.utils.*
import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
@Parcelize @Parcelize
@TypeConverters(BookSource.Converters::class) @TypeConverters(BookSource.Converters::class)
@ -92,7 +93,7 @@ data class BookSource(
} }
}.onFailure { }.onFailure {
kinds.add(ExploreKind("ERROR:${it.localizedMessage}", it.stackTraceToString())) kinds.add(ExploreKind("ERROR:${it.localizedMessage}", it.stackTraceToString()))
it.printOnDebug() Timber.e(it)
} }
} }
return@lazy kinds return@lazy kinds

@ -14,6 +14,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import org.apache.commons.text.similarity.JaccardSimilarity import org.apache.commons.text.similarity.JaccardSimilarity
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.File import java.io.File
import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CopyOnWriteArraySet
import java.util.regex.Pattern import java.util.regex.Pattern
@ -121,7 +122,7 @@ object BookHelp {
).writeBytes(it) ).writeBytes(it)
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} finally { } finally {
downloadImages.remove(src) downloadImages.remove(src)
} }

@ -3,7 +3,6 @@ package io.legado.app.help
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import android.util.Log
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.model.ReadAloud import io.legado.app.model.ReadAloud
import io.legado.app.utils.FileUtils import io.legado.app.utils.FileUtils
@ -21,7 +20,6 @@ import java.util.concurrent.TimeUnit
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler { class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
private val tag = this.javaClass.simpleName
/** /**
* 系统默认UncaughtExceptionHandler * 系统默认UncaughtExceptionHandler
@ -59,9 +57,7 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
private fun handleException(ex: Throwable?) { private fun handleException(ex: Throwable?) {
if (ex == null) return if (ex == null) return
//收集设备参数信息 //收集设备参数信息
collectDeviceInfo(context) collectDeviceInfo()
//添加自定义信息
addCustomInfo()
//保存日志文件 //保存日志文件
saveCrashInfo2File(ex) saveCrashInfo2File(ex)
context.longToastOnUi(ex.msg) context.longToastOnUi(ex.msg)
@ -70,7 +66,7 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
/** /**
* 收集设备参数信息 * 收集设备参数信息
*/ */
private fun collectDeviceInfo(ctx: Context) { private fun collectDeviceInfo() {
kotlin.runCatching { kotlin.runCatching {
//获取系统信息 //获取系统信息
paramsMap["MANUFACTURER"] = Build.MANUFACTURER paramsMap["MANUFACTURER"] = Build.MANUFACTURER
@ -83,13 +79,6 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
} }
} }
/**
* 添加自定义参数
*/
private fun addCustomInfo() {
Log.i(tag, "addCustomInfo: 程序出错了...")
}
/** /**
* 保存错误信息到文件中 * 保存错误信息到文件中
*/ */

@ -19,6 +19,7 @@ import org.apache.commons.lang3.time.DateFormatUtils
import org.jsoup.Connection import org.jsoup.Connection
import org.jsoup.Jsoup import org.jsoup.Jsoup
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
@ -49,7 +50,7 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait().body analyzeUrl.getStrResponseAwait().body
}.onFailure { }.onFailure {
log("ajax(${urlStr}) error\n${it.stackTraceToString()}") log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
it.printOnDebug() Timber.e(it)
}.getOrElse { }.getOrElse {
it.msg it.msg
} }
@ -85,7 +86,7 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait() analyzeUrl.getStrResponseAwait()
}.onFailure { }.onFailure {
log("connect(${urlStr}) error\n${it.stackTraceToString()}") log("connect(${urlStr}) error\n${it.stackTraceToString()}")
it.printOnDebug() Timber.e(it)
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -100,7 +101,7 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait() analyzeUrl.getStrResponseAwait()
}.onFailure { }.onFailure {
log("ajax($urlStr,$header) error\n${it.stackTraceToString()}") log("ajax($urlStr,$header) error\n${it.stackTraceToString()}")
it.printOnDebug() Timber.e(it)
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -510,8 +511,8 @@ interface JsExtensions {
transformation, transformation,
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: java.lang.Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -550,7 +551,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -588,7 +589,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
log(e.localizedMessage ?: "aesEncodeToByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToByteArrayERROR")
null null
} }
@ -625,7 +626,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR")
null null
} }

@ -62,7 +62,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.printOnDebug() Timber.e(e)
} }
} }
(configs ?: DefaultData.readConfigs).let { (configs ?: DefaultData.readConfigs).let {
@ -79,7 +79,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.printOnDebug() Timber.e(e)
} }
} }
shareConfig = c ?: configList.getOrNull(5) ?: Config() shareConfig = c ?: configList.getOrNull(5) ?: Config()

@ -7,6 +7,7 @@ import io.legado.app.constant.BookType
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.* import io.legado.app.data.entities.rule.*
import io.legado.app.utils.* import io.legado.app.utils.*
import timber.log.Timber
import java.util.regex.Pattern import java.util.regex.Pattern
@Suppress("RegExpRedundantEscape") @Suppress("RegExpRedundantEscape")
@ -156,7 +157,7 @@ object SourceAnalyzer {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
return source return source
} }

@ -14,6 +14,7 @@ import io.legado.app.lib.theme.ThemeStore
import io.legado.app.model.BookCover import io.legado.app.model.BookCover
import io.legado.app.utils.* import io.legado.app.utils.*
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.File import java.io.File
object ThemeConfig { object ThemeConfig {
@ -108,7 +109,7 @@ object ThemeConfig {
val json = configFile.readText() val json = configFile.readText()
return GSON.fromJsonArray(json) return GSON.fromJsonArray(json)
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
} }
} }
return null return null

@ -1,8 +1,8 @@
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 timber.log.Timber
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@ -144,7 +144,7 @@ class Coroutine<T>(
} }
} catch (e: Throwable) { } catch (e: Throwable) {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
e.printOnDebug() Timber.e(e)
} }
val consume: Boolean = errorReturn?.value?.let { value -> val consume: Boolean = errorReturn?.value?.let { value ->
if (isActive) { if (isActive) {

@ -1,7 +1,8 @@
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 timber.log.Timber
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.security.KeyManagementException import java.security.KeyManagementException
@ -126,9 +127,9 @@ object SSLHelper {
sslParams.trustManager = manager sslParams.trustManager = manager
return sslParams return sslParams
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
e.printOnDebug() Timber.e(e)
} catch (e: KeyManagementException) { } catch (e: KeyManagementException) {
e.printOnDebug() Timber.e(e)
} }
return null return null
} }
@ -142,7 +143,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.printOnDebug() Timber.e(e)
} }
return null return null
} }
@ -161,7 +162,7 @@ object SSLHelper {
try { try {
certStream.close() certStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
} }
//我们创建一个默认类型的TrustManagerFactory //我们创建一个默认类型的TrustManagerFactory

@ -9,7 +9,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
@ -179,7 +179,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.printOnDebug() Timber.e(e)
} }
if (TextUtils.isEmpty(cpuAbi)) { if (TextUtils.isEmpty(cpuAbi)) {
cpuAbi = Build.SUPPORTED_ABIS[0] cpuAbi = Build.SUPPORTED_ABIS[0]
@ -230,7 +230,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
} }
return true return true
} catch (e: Throwable) { } catch (e: Throwable) {
e.printOnDebug() Timber.e(e)
if (destFile.exists() && !destFile.delete()) { if (destFile.exists() && !destFile.delete()) {
destFile.deleteOnExit() destFile.deleteOnExit()
} }
@ -239,14 +239,14 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
try { try {
inputStream.close() inputStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
} }
if (outputStream != null) { if (outputStream != null) {
try { try {
outputStream.close() outputStream.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
} }
} }
@ -320,20 +320,20 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
} }
return true return true
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} finally { } finally {
if (fileInputStream != null) { if (fileInputStream != null) {
try { try {
fileInputStream.close() fileInputStream.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
if (os != null) { if (os != null) {
try { try {
os.close() os.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
} }
@ -355,15 +355,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.printOnDebug() Timber.e(e)
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
e.printOnDebug() Timber.e(e)
} finally { } finally {
if (fileInputStream != null) { if (fileInputStream != null) {
try { try {
fileInputStream.close() fileInputStream.close()
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
} }

@ -4,7 +4,8 @@ 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 timber.log.Timber
import java.io.File import java.io.File
object Preferences { object Preferences {
@ -37,11 +38,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.printOnDebug() Timber.e(e)
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
e.printOnDebug() Timber.e(e)
} catch (e: IllegalAccessException) { } catch (e: IllegalAccessException) {
e.printOnDebug() Timber.e(e)
} }
return null return null
} }

@ -20,6 +20,7 @@ import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.File import java.io.File
@ -92,7 +93,7 @@ object Restore {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
} }
@ -168,7 +169,7 @@ object Restore {
ThemeConfig.upConfig() ThemeConfig.upConfig()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
if (!ignoreReadConfig) { if (!ignoreReadConfig) {
//恢复阅读界面配置 //恢复阅读界面配置
@ -181,7 +182,7 @@ object Restore {
ReadBookConfig.initConfigs() ReadBookConfig.initConfigs()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
try { try {
val file = val file =
@ -192,7 +193,7 @@ object Restore {
ReadBookConfig.initShareConfig() ReadBookConfig.initShareConfig()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
Preferences.getSharedPreferences(appCtx, path, "config")?.all?.let { map -> Preferences.getSharedPreferences(appCtx, path, "config")?.all?.let { map ->
@ -262,7 +263,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.printOnDebug() Timber.e(e)
} }
return null return null
} }

@ -3,13 +3,13 @@ package io.legado.app.lib.webdav
import io.legado.app.help.http.newCallResponseBody import io.legado.app.help.http.newCallResponseBody
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
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
import org.intellij.lang.annotations.Language import org.intellij.lang.annotations.Language
import org.jsoup.Jsoup import org.jsoup.Jsoup
import timber.log.Timber
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
import java.net.MalformedURLException import java.net.MalformedURLException
@ -101,8 +101,8 @@ class WebDav(urlStr: String) {
val requestBody = requestPropsStr.toRequestBody("text/plain".toMediaType()) val requestBody = requestPropsStr.toRequestBody("text/plain".toMediaType())
method("PROPFIND", requestBody) method("PROPFIND", requestBody)
}.text() }.text()
}.onFailure { }.onFailure { e ->
it.printOnDebug() Timber.e(e)
}.getOrNull() }.getOrNull()
} }
return null return null
@ -134,7 +134,7 @@ class WebDav(urlStr: String) {
} }
list.add(webDavFile) list.add(webDavFile)
} catch (e: MalformedURLException) { } catch (e: MalformedURLException) {
e.printOnDebug() Timber.e(e)
} }
} }
} }

@ -12,10 +12,11 @@ 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
import timber.log.Timber
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@ -177,7 +178,7 @@ object CacheBook {
"下载${book.name}-${chapterTitle}失败\n${error.localizedMessage}", "下载${book.name}-${chapterTitle}失败\n${error.localizedMessage}",
error error
) )
error.printOnDebug() Timber.e(error)
} }
} }

@ -16,13 +16,14 @@ 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
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
@Suppress("MemberVisibilityCanBePrivate") @Suppress("MemberVisibilityCanBePrivate")
@ -365,7 +366,7 @@ object ReadBook : CoroutineScope by MainScope() {
} }
} }
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}") appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}")
}.onSuccess { }.onSuccess {
success?.invoke() success?.invoke()

@ -3,7 +3,8 @@ 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 timber.log.Timber
import java.util.* import java.util.*
@Suppress("RegExpRedundantEscape") @Suppress("RegExpRedundantEscape")
@ -49,7 +50,7 @@ class AnalyzeByJSonPath(json: Any) {
ob.toString() ob.toString()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
return result return result
@ -86,7 +87,7 @@ class AnalyzeByJSonPath(json: Any) {
result.add(obj.toString()) result.add(obj.toString())
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} else { } else {
result.add(st) result.add(st)
@ -136,7 +137,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.printOnDebug() Timber.e(e)
} }
} }
} else { } else {

@ -14,6 +14,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.jsoup.nodes.Entities import org.jsoup.nodes.Entities
import org.mozilla.javascript.NativeObject import org.mozilla.javascript.NativeObject
import timber.log.Timber
import java.net.URL import java.net.URL
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
@ -658,7 +659,7 @@ class AnalyzeRule(
analyzeUrl.getStrResponseAwait().body analyzeUrl.getStrResponseAwait().body
}.onFailure { }.onFailure {
log("ajax(${urlStr}) error\n${it.stackTraceToString()}") log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
it.printOnDebug() Timber.e(it)
}.getOrElse { }.getOrElse {
it.msg it.msg
} }

@ -6,11 +6,15 @@ 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.* import io.legado.app.utils.FileUtils
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
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
@ -94,7 +98,7 @@ class EpubFile(var book: Book) {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
@ -108,7 +112,7 @@ class EpubFile(var book: Book) {
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
return null return null
} }
@ -205,7 +209,7 @@ class EpubFile(var book: Book) {
title = elements[0].text() title = elements[0].text()
} }
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
} }
val chapter = BookChapter() val chapter = BookChapter()

@ -4,10 +4,14 @@ 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.* import io.legado.app.utils.FileUtils
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
import timber.log.Timber
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
import java.util.* import java.util.*
@ -79,7 +83,7 @@ class UmdFile(var book: Book) {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }

@ -32,6 +32,7 @@ import io.legado.app.ui.book.audio.AudioPlayActivity
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import timber.log.Timber
class AudioPlayService : BaseService(), class AudioPlayService : BaseService(),
@ -139,7 +140,7 @@ class AudioPlayService : BaseService(),
exoPlayer.playWhenReady = true exoPlayer.playWhenReady = true
exoPlayer.prepare() exoPlayer.prepare()
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
toastOnUi("$url ${it.localizedMessage}") toastOnUi("$url ${it.localizedMessage}")
stopSelf() stopSelf()
} }
@ -160,7 +161,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.printOnDebug() Timber.e(e)
} }
} }
@ -179,7 +180,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.printOnDebug() Timber.e(e)
stopSelf() stopSelf()
} }
} }
@ -251,7 +252,7 @@ class AudioPlayService : BaseService(),
val errorMsg = "音频播放出错\n${error.errorCodeName} ${error.errorCode}" val errorMsg = "音频播放出错\n${error.errorCodeName} ${error.errorCode}"
AppLog.put(errorMsg, error) AppLog.put(errorMsg, error)
toastOnUi(errorMsg) toastOnUi(errorMsg)
error.printOnDebug() Timber.e(error)
} }
private fun setTimer(minute: Int) { private fun setTimer(minute: Int) {

@ -17,6 +17,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import okhttp3.Response import okhttp3.Response
import timber.log.Timber
import java.io.File import java.io.File
import java.io.FileDescriptor import java.io.FileDescriptor
import java.io.FileInputStream import java.io.FileInputStream
@ -196,7 +197,7 @@ class HttpReadAloudService : BaseReadAloudService(),
createSilentSound(fileName) createSilentSound(fileName)
AppLog.put("tts接口错误\n${e.localizedMessage}", e) AppLog.put("tts接口错误\n${e.localizedMessage}", e)
toastOnUi("tts接口错误\n${e.localizedMessage}") toastOnUi("tts接口错误\n${e.localizedMessage}")
e.printOnDebug() Timber.e(e)
} }
} }
} }
@ -213,7 +214,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.printOnDebug() Timber.e(e)
} }
} }
} }

@ -14,6 +14,7 @@ import io.legado.app.ui.main.MainActivity
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.web.HttpServer import io.legado.app.web.HttpServer
import io.legado.app.web.WebSocketServer import io.legado.app.web.WebSocketServer
import timber.log.Timber
import java.io.IOException import java.io.IOException
class WebService : BaseService() { class WebService : BaseService() {
@ -87,7 +88,7 @@ class WebService : BaseService() {
upNotification() upNotification()
} catch (e: IOException) { } catch (e: IOException) {
toastOnUi(e.localizedMessage ?: "") toastOnUi(e.localizedMessage ?: "")
e.printOnDebug() Timber.e(e)
stopSelf() stopSelf()
} }
} else { } else {

@ -6,7 +6,8 @@ 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 timber.log.Timber
/** /**
* web服务快捷开关 * web服务快捷开关
@ -27,7 +28,7 @@ class WebTileService : TileService() {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }

@ -7,7 +7,11 @@ 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.* import io.legado.app.utils.ACache
import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.openUrl
import io.legado.app.utils.sendToClip
import timber.log.Timber
class DonateFragment : PreferenceFragmentCompat() { class DonateFragment : PreferenceFragmentCompat() {
@ -46,7 +50,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.printOnDebug() Timber.e(e)
} finally { } finally {
ACache.get(requireContext(), cacheDir = false) ACache.get(requireContext(), cacheDir = false)
.put("proTime", System.currentTimeMillis()) .put("proTime", System.currentTimeMillis())

@ -8,8 +8,9 @@ import io.legado.app.base.BaseViewModel
import io.legado.app.model.NoStackTraceException 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.readText import io.legado.app.utils.readText
import timber.log.Timber
import java.io.File import java.io.File
class FileAssociationViewModel(application: Application) : BaseViewModel(application) { class FileAssociationViewModel(application: Application) : BaseViewModel(application) {
@ -54,7 +55,7 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica
onLineImportLive.postValue(uri) onLineImportLive.postValue(uri)
} }
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
} }
} }

@ -17,6 +17,7 @@ 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.NoStackTraceException
import io.legado.app.utils.* import io.legado.app.utils.*
import timber.log.Timber
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
var isAddGroup = false var isAddGroup = false
@ -113,7 +114,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
else -> throw NoStackTraceException(context.getString(R.string.wrong_format)) else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
} }
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
errorLiveData.postValue(it.localizedMessage ?: "") errorLiveData.postValue(it.localizedMessage ?: "")
}.onSuccess { }.onSuccess {
comparisonSource() comparisonSource()

@ -28,6 +28,7 @@ import me.ag2s.epublib.domain.*
import me.ag2s.epublib.epub.EpubWriter import me.ag2s.epublib.epub.EpubWriter
import me.ag2s.epublib.util.ResourceUtil import me.ag2s.epublib.util.ResourceUtil
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@ -70,7 +71,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
exportProgress.remove(book.bookUrl) exportProgress.remove(book.bookUrl)
exportMsg[book.bookUrl] = it.localizedMessage ?: "ERROR" exportMsg[book.bookUrl] = it.localizedMessage ?: "ERROR"
upAdapterLiveData.postValue(book.bookUrl) upAdapterLiveData.postValue(book.bookUrl)
it.printOnDebug() Timber.e(it)
}.onSuccess { }.onSuccess {
exportProgress.remove(book.bookUrl) exportProgress.remove(book.bookUrl)
exportMsg[book.bookUrl] = context.getString(R.string.export_success) exportMsg[book.bookUrl] = context.getString(R.string.export_success)
@ -205,7 +206,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
exportProgress.remove(book.bookUrl) exportProgress.remove(book.bookUrl)
exportMsg[book.bookUrl] = it.localizedMessage ?: "ERROR" exportMsg[book.bookUrl] = it.localizedMessage ?: "ERROR"
upAdapterLiveData.postValue(book.bookUrl) upAdapterLiveData.postValue(book.bookUrl)
it.printOnDebug() Timber.e(it)
}.onSuccess { }.onSuccess {
exportProgress.remove(book.bookUrl) exportProgress.remove(book.bookUrl)
exportMsg[book.bookUrl] = context.getString(R.string.export_success) exportMsg[book.bookUrl] = context.getString(R.string.export_success)

@ -17,10 +17,11 @@ 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
import timber.log.Timber
import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.min import kotlin.math.min
@ -187,7 +188,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook) searchFinish(searchBook)
} }
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
} }
} }
@ -198,7 +199,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
val searchBook: SearchBook = book.toSearchBook() val searchBook: SearchBook = book.toSearchBook()
searchFinish(searchBook) searchFinish(searchBook)
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
} }
} }

@ -10,8 +10,9 @@ 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
import timber.log.Timber
class ExploreShowViewModel(application: Application) : BaseViewModel(application) { class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
@ -43,7 +44,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
appDb.searchBookDao.insert(*searchBooks.toTypedArray()) appDb.searchBookDao.insert(*searchBooks.toTypedArray())
page++ page++
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
errorLiveData.postValue(it.msg) errorLiveData.postValue(it.msg)
} }
} }

@ -24,6 +24,7 @@ import io.legado.app.databinding.ItemTextBinding
import io.legado.app.databinding.PopupActionMenuBinding import io.legado.app.databinding.PopupActionMenuBinding
import io.legado.app.service.BaseReadAloudService import io.legado.app.service.BaseReadAloudService
import io.legado.app.utils.* import io.legado.app.utils.*
import timber.log.Timber
import java.util.* import java.util.*
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
@ -209,7 +210,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
} }
context.startActivity(intent) context.startActivity(intent)
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
context.toastOnUi(it.localizedMessage ?: "ERROR") context.toastOnUi(it.localizedMessage ?: "ERROR")
} }
} }

@ -28,6 +28,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.document.HandleFileContract
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 timber.log.Timber
import java.io.File import java.io.File
class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) { class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
@ -273,7 +274,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
}.onSuccess { }.onSuccess {
toastOnUi("导出成功, 文件名为 $exportFileName") toastOnUi("导出成功, 文件名为 $exportFileName")
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
longToast("导出失败:${it.localizedMessage}") longToast("导出失败:${it.localizedMessage}")
} }
} }
@ -310,7 +311,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
importConfig(uri.readBytes(requireContext())!!) importConfig(uri.readBytes(requireContext())!!)
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
longToast("导入失败:${it.localizedMessage}") longToast("导入失败:${it.localizedMessage}")
} }
} }
@ -324,7 +325,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
toastOnUi("导入成功") toastOnUi("导入成功")
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
longToast("导入失败:${it.localizedMessage}") longToast("导入失败:${it.localizedMessage}")
} }
} }

@ -11,6 +11,7 @@ import io.legado.app.help.http.okHttpClient
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import timber.log.Timber
class BookSourceEditViewModel(application: Application) : BaseViewModel(application) { class BookSourceEditViewModel(application: Application) : BaseViewModel(application) {
@ -48,7 +49,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
success?.invoke() success?.invoke()
}.onError { }.onError {
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
it.printOnDebug() Timber.e(it)
} }
} }
@ -62,7 +63,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
} }
}.onError { }.onError {
context.toastOnUi(it.localizedMessage ?: "Error") context.toastOnUi(it.localizedMessage ?: "Error")
it.printOnDebug() Timber.e(it)
} }
} }

@ -14,6 +14,7 @@ import io.legado.app.help.http.okHttpClient
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.* import io.legado.app.utils.*
import timber.log.Timber
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -40,7 +41,7 @@ class WebViewModel(application: Application) : BaseViewModel(application) {
success.invoke() success.invoke()
}.onError { }.onError {
context.toastOnUi("error\n${it.localizedMessage}") context.toastOnUi("error\n${it.localizedMessage}")
it.printOnDebug() Timber.e(it)
} }
} }

@ -9,8 +9,9 @@ import io.legado.app.constant.AppLog
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 timber.log.Timber
import java.io.File import java.io.File
class HandleFileViewModel(application: Application) : BaseViewModel(application) { class HandleFileViewModel(application: Application) : BaseViewModel(application) {
@ -29,7 +30,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application)
success.invoke(it) success.invoke(it)
}.onError { }.onError {
AppLog.put("上传文件失败\n${it.localizedMessage}", it) AppLog.put("上传文件失败\n${it.localizedMessage}", it)
it.printOnDebug() Timber.e(it)
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
} }
} }
@ -49,7 +50,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application)
Uri.fromFile(newFile) Uri.fromFile(newFile)
} }
}.onError { }.onError {
it.printOnDebug() Timber.e(it)
errorLiveData.postValue(it.localizedMessage) errorLiveData.postValue(it.localizedMessage)
}.onSuccess { }.onSuccess {
success.invoke(it) success.invoke(it)

@ -24,6 +24,7 @@ import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import splitties.views.onClick import splitties.views.onClick
import timber.log.Timber
class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) { class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) {
@ -123,7 +124,7 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) {
} catch (e: Exception) { } catch (e: Exception) {
AppLog.put("登录出错\n${e.localizedMessage}", e) AppLog.put("登录出错\n${e.localizedMessage}", e)
context?.toastOnUi("登录出错\n${e.localizedMessage}") context?.toastOnUi("登录出错\n${e.localizedMessage}")
e.printOnDebug() Timber.e(e)
} }
} }
} }

@ -17,8 +17,9 @@ import io.legado.app.model.CacheBook
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 kotlinx.coroutines.* import kotlinx.coroutines.*
import timber.log.Timber
import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.min import kotlin.math.min
@ -126,7 +127,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
addDownload(source, book) addDownload(source, book)
}.onError(upTocPool) { }.onError(upTocPool) {
AppLog.put("${book.name} 更新目录失败\n${it.localizedMessage}", it) AppLog.put("${book.name} 更新目录失败\n${it.localizedMessage}", it)
it.printOnDebug() Timber.e(it)
}.onCancel(upTocPool) { }.onCancel(upTocPool) {
upTocCancel(book.bookUrl) upTocCancel(book.bookUrl)
}.onFinally(upTocPool) { }.onFinally(upTocPool) {

@ -9,10 +9,11 @@ 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
import timber.log.Timber
class RssArticlesViewModel(application: Application) : BaseViewModel(application) { class RssArticlesViewModel(application: Application) : BaseViewModel(application) {
val loadFinally = MutableLiveData<Boolean>() val loadFinally = MutableLiveData<Boolean>()
@ -53,7 +54,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
} }
}.onError { }.onError {
loadFinally.postValue(false) loadFinally.postValue(false)
it.printOnDebug() Timber.e(it)
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
} }
} }
@ -69,7 +70,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
loadMoreSuccess(it.first) loadMoreSuccess(it.first)
} }
.onError { .onError {
it.printOnDebug() Timber.e(it)
loadFinally.postValue(false) loadFinally.postValue(false)
} }
} else { } else {

@ -7,9 +7,10 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.utils.getClipText import io.legado.app.utils.getClipText
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.Dispatchers import kotlinx.coroutines.Dispatchers
import timber.log.Timber
class RssSourceEditViewModel(application: Application) : BaseViewModel(application) { class RssSourceEditViewModel(application: Application) : BaseViewModel(application) {
@ -41,7 +42,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
success() success()
}.onError { }.onError {
context.toastOnUi(it.localizedMessage) context.toastOnUi(it.localizedMessage)
it.printOnDebug() Timber.e(it)
} }
} }

@ -15,7 +15,8 @@ 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 import timber.log.Timber
class SearchView @JvmOverloads constructor( class SearchView @JvmOverloads constructor(
context: Context, context: Context,
@ -43,7 +44,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.printOnDebug() Timber.e(e)
} }
} }

@ -22,7 +22,8 @@ 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 timber.log.Timber
import kotlin.math.roundToInt import kotlin.math.roundToInt
object Utils { object Utils {
@ -66,7 +67,7 @@ object Utils {
try { try {
return Bitmap.createBitmap(width, height, config) return Bitmap.createBitmap(width, height, config)
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
e.printOnDebug() Timber.e(e)
if (retryCount > 0) { if (retryCount > 0) {
System.gc() System.gc()
return createBitmapSafely(width, height, config, retryCount - 1) return createBitmapSafely(width, height, config, retryCount - 1)

@ -8,6 +8,7 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.databinding.ItemFontBinding import io.legado.app.databinding.ItemFontBinding
import io.legado.app.utils.* import io.legado.app.utils.*
import timber.log.Timber
import java.io.File import java.io.File
import java.net.URLDecoder import java.net.URLDecoder
@ -41,7 +42,7 @@ class FontAdapter(context: Context, val callBack: CallBack) :
} }
tvFont.typeface = typeface tvFont.typeface = typeface
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
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,8 +20,9 @@ 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 timber.log.Timber
import kotlin.math.min import kotlin.math.min
import kotlin.math.pow import kotlin.math.pow
@ -317,7 +318,7 @@ class CircleImageView @JvmOverloads constructor(
drawable.draw(canvas) drawable.draw(canvas)
bitmap bitmap
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
null null
} }

@ -8,10 +8,10 @@ import android.graphics.Canvas
import android.graphics.PixelFormat import android.graphics.PixelFormat
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.util.Log
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.* import java.io.*
import java.util.* import java.util.*
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
@ -70,11 +70,11 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
init { init {
try { try {
if (!cacheDir.exists() && !cacheDir.mkdirs()) { if (!cacheDir.exists() && !cacheDir.mkdirs()) {
Log.i("ACache", "can't make dirs in %s" + cacheDir.absolutePath) Timber.i("can't make dirs in %s" + cacheDir.absolutePath)
} }
mCache = ACacheManager(cacheDir, max_size, max_count) mCache = ACacheManager(cacheDir, max_size, max_count)
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
@ -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.printOnDebug() Timber.e(e)
} }
} }
} }
@ -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.printOnDebug() Timber.e(e)
} 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.printOnDebug() Timber.e(e)
} 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.printOnDebug() Timber.e(e)
} }
} }
@ -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.printOnDebug() Timber.e(e)
} finally { } finally {
try { try {
bis?.close() bis?.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
try { try {
ois?.close() ois?.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
} }
@ -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.printOnDebug() Timber.e(e)
} }
} }
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.printOnDebug() Timber.e(e)
} }
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.printOnDebug() Timber.e(e)
} }
@ -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.printOnDebug() Timber.e(e)
} }
} }
@ -727,7 +727,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
} }
@ -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.printOnDebug() Timber.e(e)
return 0 return 0
} }

@ -27,6 +27,7 @@ import androidx.preference.PreferenceManager
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import timber.log.Timber
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@ -158,7 +159,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.printOnDebug() Timber.e(e)
} }
return screenOffTime return screenOffTime
} }
@ -316,7 +317,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.printOnDebug() Timber.e(e)
} }
return "" return ""
} }

@ -5,6 +5,7 @@ import android.database.Cursor
import android.net.Uri import android.net.Uri
import android.provider.DocumentsContract import android.provider.DocumentsContract
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import timber.log.Timber
import java.nio.charset.Charset import java.nio.charset.Charset
import java.util.* import java.util.*
@ -131,7 +132,7 @@ object DocumentUtils {
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} finally { } finally {
cursor?.close() cursor?.close()
} }

@ -5,6 +5,7 @@ import android.webkit.MimeTypeMap
import androidx.annotation.IntDef import androidx.annotation.IntDef
import io.legado.app.ui.document.utils.ConvertUtils import io.legado.app.ui.document.utils.ConvertUtils
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.* import java.io.*
import java.nio.charset.Charset import java.nio.charset.Charset
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -46,7 +47,7 @@ object FileUtils {
file.createNewFile() file.createNewFile()
} }
} catch (e: IOException) { } catch (e: IOException) {
e.printOnDebug() Timber.e(e)
} }
return file return file
} }
@ -116,8 +117,8 @@ object FileUtils {
var sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath var sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath
try { try {
sdCardDirectory = File(sdCardDirectory).canonicalPath sdCardDirectory = File(sdCardDirectory).canonicalPath
} catch (ioe: IOException) { } catch (e: IOException) {
ioe.printOnDebug() Timber.e(e)
} }
return sdCardDirectory return sdCardDirectory
} }

@ -3,6 +3,7 @@ package io.legado.app.utils
import com.google.gson.* import com.google.gson.*
import com.google.gson.internal.LinkedTreeMap import com.google.gson.internal.LinkedTreeMap
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import timber.log.Timber
import java.lang.reflect.ParameterizedType import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type import java.lang.reflect.Type
import kotlin.math.ceil import kotlin.math.ceil
@ -26,7 +27,7 @@ inline fun <reified T> Gson.fromJsonObject(json: String?): T? {//可转成任意
return kotlin.runCatching { return kotlin.runCatching {
fromJson(json, genericType<T>()) as? T fromJson(json, genericType<T>()) as? T
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
}.getOrNull() }.getOrNull()
} }
@ -34,7 +35,7 @@ inline fun <reified T> Gson.fromJsonArray(json: String?): List<T>? {
return kotlin.runCatching { return kotlin.runCatching {
fromJson(json, ParameterizedTypeImpl(T::class.java)) as? List<T> fromJson(json, ParameterizedTypeImpl(T::class.java)) as? List<T>
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
}.getOrNull() }.getOrNull()
} }

@ -3,7 +3,6 @@
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.*
@ -71,12 +70,6 @@ object LogUtils {
} }
} }
fun Throwable.printOnDebug() {
if (BuildConfig.DEBUG) {
printStackTrace()
}
}
fun dLog(tag: String, msg: String) { fun dLog(tag: String, msg: String) {
LogUtils.d(tag, msg) LogUtils.d(tag, msg)
} }

@ -1,5 +1,6 @@
package io.legado.app.utils package io.legado.app.utils
import timber.log.Timber
import java.security.MessageDigest import java.security.MessageDigest
import java.security.NoSuchAlgorithmException import java.security.NoSuchAlgorithmException
@ -25,7 +26,7 @@ object MD5Utils {
} }
reStr = stringBuffer.toString() reStr = stringBuffer.toString()
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
e.printOnDebug() Timber.e(e)
} }
return reStr return reStr

@ -4,6 +4,7 @@ import android.net.ConnectivityManager
import android.net.NetworkCapabilities import android.net.NetworkCapabilities
import android.os.Build import android.os.Build
import splitties.systemservices.connectivityManager import splitties.systemservices.connectivityManager
import timber.log.Timber
import java.net.InetAddress import java.net.InetAddress
import java.net.NetworkInterface import java.net.NetworkInterface
import java.net.SocketException import java.net.SocketException
@ -114,7 +115,7 @@ object NetworkUtils {
relativeUrl = parseUrl.toString() relativeUrl = parseUrl.toString()
return relativeUrl return relativeUrl
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
return relativeUrl return relativeUrl
} }
@ -130,7 +131,7 @@ object NetworkUtils {
relativeUrl = parseUrl.toString() relativeUrl = parseUrl.toString()
return relativeUrl return relativeUrl
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
} }
return relativeUrl return relativeUrl
} }
@ -158,7 +159,7 @@ object NetworkUtils {
try { try {
enumeration = NetworkInterface.getNetworkInterfaces() enumeration = NetworkInterface.getNetworkInterfaces()
} catch (e: SocketException) { } catch (e: SocketException) {
e.printOnDebug() Timber.e(e)
} }
if (enumeration != null) { if (enumeration != null) {

@ -9,6 +9,7 @@ import android.os.Build
import android.os.Environment import android.os.Environment
import android.provider.DocumentsContract import android.provider.DocumentsContract
import android.provider.MediaStore import android.provider.MediaStore
import timber.log.Timber
import java.io.File import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.io.FileOutputStream import java.io.FileOutputStream
@ -111,7 +112,7 @@ object RealPathUtil {
return cursor.getString(index) return cursor.getString(index)
} }
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
e.printOnDebug() Timber.e(e)
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 +131,7 @@ object RealPathUtil {
} }
return File(filePath).absolutePath return File(filePath).absolutePath
} catch (ignored: IOException) { } catch (ignored: IOException) {
ignored.printOnDebug() Timber.e(ignored)
} finally { } finally {
input?.close() input?.close()
output?.close() output?.close()

@ -2,6 +2,7 @@ package io.legado.app.utils
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.text.TextUtils.isEmpty import android.text.TextUtils.isEmpty
import timber.log.Timber
import java.text.DecimalFormat import java.text.DecimalFormat
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -95,7 +96,7 @@ object StringUtils {
} }
} }
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
} }
return "" return ""
} }

@ -8,6 +8,7 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.PowerManager import android.os.PowerManager
import android.provider.Settings import android.provider.Settings
import timber.log.Timber
@Suppress("unused") @Suppress("unused")
@ -21,7 +22,7 @@ object SystemUtils {
Settings.System.SCREEN_OFF_TIMEOUT Settings.System.SCREEN_OFF_TIMEOUT
) )
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
} }
return screenOffTime return screenOffTime

@ -9,6 +9,7 @@ import io.legado.app.R
import io.legado.app.lib.permission.Permissions import io.legado.app.lib.permission.Permissions
import io.legado.app.lib.permission.PermissionsCompat import io.legado.app.lib.permission.PermissionsCompat
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import timber.log.Timber
import java.io.File import java.io.File
fun Uri.isContentScheme() = this.scheme == "content" fun Uri.isContentScheme() = this.scheme == "content"
@ -42,7 +43,7 @@ fun AppCompatActivity.readUri(uri: Uri?, success: (name: String, bytes: ByteArra
.request() .request()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
toastOnUi(e.localizedMessage ?: "read uri error") toastOnUi(e.localizedMessage ?: "read uri error")
} }
} }
@ -76,7 +77,7 @@ fun Fragment.readUri(uri: Uri?, success: (name: String, bytes: ByteArray) -> Uni
.request() .request()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printOnDebug() Timber.e(e)
toastOnUi(e.localizedMessage ?: "read uri error") toastOnUi(e.localizedMessage ?: "read uri error")
} }
} }

@ -22,6 +22,7 @@ import androidx.viewpager.widget.ViewPager
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.TintHelper import io.legado.app.lib.theme.TintHelper
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.lang.reflect.Field import java.lang.reflect.Field
@ -171,6 +172,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.printOnDebug() Timber.e(it)
} }
} }

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

@ -10,6 +10,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.IOException import java.io.IOException
@ -86,7 +87,7 @@ class BookSourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) :
close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false)
} }
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
} }
} }
} }

@ -10,6 +10,7 @@ import io.legado.app.utils.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import splitties.init.appCtx import splitties.init.appCtx
import timber.log.Timber
import java.io.IOException import java.io.IOException
@ -85,7 +86,7 @@ class RssSourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) :
close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false)
} }
}.onFailure { }.onFailure {
it.printOnDebug() Timber.e(it)
} }
} }
} }

Loading…
Cancel
Save