This commit is contained in:
gedoor 2021-10-19 09:28:01 +08:00
parent cb7cec81fd
commit 2d0d7447ef
60 changed files with 214 additions and 168 deletions

View File

@ -20,6 +20,7 @@ import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.*
import kotlinx.coroutines.runBlocking
import splitties.init.appCtx
import timber.log.Timber
object BookController {
@ -209,7 +210,7 @@ object BookController {
if (book.isUmd()) UmdFile.upBookInfo(book)
appDb.bookDao.insert(book)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
return returnData.setErrorMsg(
e.localizedMessage ?: appCtx.getString(R.string.unknown_error)
)

View File

@ -7,7 +7,11 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.CacheManager
import io.legado.app.help.JsExtensions
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
/**
@ -107,7 +111,7 @@ interface BaseSource : JsExtensions {
?: return null
return String(decodeBytes)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
return null
}
}
@ -127,7 +131,7 @@ interface BaseSource : JsExtensions {
CacheManager.put("userInfo_${getKey()}", encodeStr)
true
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
false
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -62,7 +62,7 @@ object ReadBookConfig {
val json = configFile.readText()
configs = GSON.fromJsonArray(json)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
(configs ?: DefaultData.readConfigs).let {
@ -79,7 +79,7 @@ object ReadBookConfig {
val json = configFile.readText()
c = GSON.fromJsonObject(json)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
shareConfig = c ?: configList.getOrNull(5) ?: Config()

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import com.google.android.gms.net.CronetProviderInstaller
import io.legado.app.BuildConfig
import io.legado.app.help.AppConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.utils.printOnDebug
import org.chromium.net.CronetEngine
import org.json.JSONObject
import splitties.init.appCtx
@ -179,7 +179,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
abiField.isAccessible = true
cpuAbi = abiField.get(appInfo) as String?
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
if (TextUtils.isEmpty(cpuAbi)) {
cpuAbi = Build.SUPPORTED_ABIS[0]
@ -230,7 +230,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
}
return true
} catch (e: Throwable) {
e.printOnDebug()
Timber.e(e)
if (destFile.exists() && !destFile.delete()) {
destFile.deleteOnExit()
}
@ -239,14 +239,14 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
try {
inputStream.close()
} catch (e: IOException) {
e.printOnDebug()
Timber.e(e)
}
}
if (outputStream != null) {
try {
outputStream.close()
} catch (e: IOException) {
e.printOnDebug()
Timber.e(e)
}
}
}
@ -320,20 +320,20 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
}
return true
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close()
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
if (os != null) {
try {
os.close()
} 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()
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
} catch (e: OutOfMemoryError) {
e.printOnDebug()
Timber.e(e)
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close()
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
}

View File

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

View File

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

View File

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

View File

@ -12,10 +12,11 @@ import io.legado.app.help.BookHelp
import io.legado.app.model.webBook.WebBook
import io.legado.app.service.CacheBookService
import io.legado.app.utils.postEvent
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.startService
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import timber.log.Timber
import java.util.concurrent.ConcurrentHashMap
import kotlin.coroutines.CoroutineContext
@ -177,7 +178,7 @@ object CacheBook {
"下载${book.name}-${chapterTitle}失败\n${error.localizedMessage}",
error
)
error.printOnDebug()
Timber.e(error)
}
}

View File

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

View File

@ -3,7 +3,8 @@ package io.legado.app.model.analyzeRule
import androidx.annotation.Keep
import com.jayway.jsonpath.JsonPath
import com.jayway.jsonpath.ReadContext
import io.legado.app.utils.printOnDebug
import timber.log.Timber
import java.util.*
@Suppress("RegExpRedundantEscape")
@ -49,7 +50,7 @@ class AnalyzeByJSonPath(json: Any) {
ob.toString()
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
return result
@ -86,7 +87,7 @@ class AnalyzeByJSonPath(json: Any) {
result.add(obj.toString())
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
} else {
result.add(st)
@ -136,7 +137,7 @@ class AnalyzeByJSonPath(json: Any) {
try {
return it.read<ArrayList<Any>>(rules[0])
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
} else {

View File

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

View File

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

View File

@ -4,10 +4,14 @@ import android.net.Uri
import android.util.Log
import io.legado.app.data.entities.Book
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.umd.UmdReader
import splitties.init.appCtx
import timber.log.Timber
import java.io.File
import java.io.InputStream
import java.util.*
@ -79,7 +83,7 @@ class UmdFile(var book: Book) {
}
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}

View File

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

View File

@ -17,6 +17,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import okhttp3.Response
import timber.log.Timber
import java.io.File
import java.io.FileDescriptor
import java.io.FileInputStream
@ -196,7 +197,7 @@ class HttpReadAloudService : BaseReadAloudService(),
createSilentSound(fileName)
AppLog.put("tts接口错误\n${e.localizedMessage}", e)
toastOnUi("tts接口错误\n${e.localizedMessage}")
e.printOnDebug()
Timber.e(e)
}
}
}
@ -213,7 +214,7 @@ class HttpReadAloudService : BaseReadAloudService(),
playingIndex = nowSpeak
postEvent(EventBus.TTS_PROGRESS, readAloudNumber + 1)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
}

View File

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

View File

@ -6,7 +6,8 @@ import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import io.legado.app.constant.IntentAction
import io.legado.app.utils.printOnDebug
import timber.log.Timber
/**
* web服务快捷开关
@ -27,7 +28,7 @@ class WebTileService : TileService() {
}
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
return super.onStartCommand(intent, flags, startId)
}

View File

@ -7,7 +7,11 @@ import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
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() {
@ -46,7 +50,7 @@ class DonateFragment : PreferenceFragmentCompat() {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
} finally {
ACache.get(requireContext(), cacheDir = false)
.put("proTime", System.currentTimeMillis())

View File

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

View File

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

View File

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

View File

@ -17,10 +17,11 @@ import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefString
import io.legado.app.utils.printOnDebug
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO
import splitties.init.appCtx
import timber.log.Timber
import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors
import kotlin.math.min
@ -187,7 +188,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
searchFinish(searchBook)
}
}.onError {
it.printOnDebug()
Timber.e(it)
}
}
@ -198,7 +199,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
val searchBook: SearchBook = book.toSearchBook()
searchFinish(searchBook)
}.onError {
it.printOnDebug()
Timber.e(it)
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,10 +9,11 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.RssArticle
import io.legado.app.data.entities.RssSource
import io.legado.app.model.rss.Rss
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import timber.log.Timber
class RssArticlesViewModel(application: Application) : BaseViewModel(application) {
val loadFinally = MutableLiveData<Boolean>()
@ -53,7 +54,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
}
}.onError {
loadFinally.postValue(false)
it.printOnDebug()
Timber.e(it)
context.toastOnUi(it.localizedMessage)
}
}
@ -69,7 +70,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
loadMoreSuccess(it.first)
}
.onError {
it.printOnDebug()
Timber.e(it)
loadFinally.postValue(false)
}
} else {

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.databinding.ItemFontBinding
import io.legado.app.utils.*
import timber.log.Timber
import java.io.File
import java.net.URLDecoder
@ -41,7 +42,7 @@ class FontAdapter(context: Context, val callBack: CallBack) :
}
tvFont.typeface = typeface
}.onFailure {
it.printOnDebug()
Timber.e(it)
context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}")
}
tvFont.text = item.name

View File

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

View File

@ -8,10 +8,10 @@ import android.graphics.Canvas
import android.graphics.PixelFormat
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.Log
import org.json.JSONArray
import org.json.JSONObject
import splitties.init.appCtx
import timber.log.Timber
import java.io.*
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
@ -70,11 +70,11 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
init {
try {
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)
} 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)
mCache.put(file)
} 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
}
} catch (e: IOException) {
e.printOnDebug()
Timber.e(e)
} finally {
if (removeFile)
remove(key)
@ -269,7 +269,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
null
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
} finally {
if (removeFile)
remove(key)
@ -299,7 +299,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
}
}
} 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)
return ois.readObject()
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
} finally {
try {
bis?.close()
} catch (e: IOException) {
e.printOnDebug()
Timber.e(e)
}
try {
ois?.close()
} 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
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
}
return null
@ -488,7 +488,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
}
}
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
return false
@ -662,7 +662,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
cacheCount.set(count)
}
} 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)
lastUsageDates[file] = currentTime
} 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) {
e.printOnDebug()
Timber.e(e)
}
}
@ -767,7 +767,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
}
return fileSize
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
return 0
}

View File

@ -27,6 +27,7 @@ import androidx.preference.PreferenceManager
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
import io.legado.app.R
import io.legado.app.constant.AppConst
import timber.log.Timber
import java.io.File
import java.io.FileOutputStream
@ -158,7 +159,7 @@ val Context.sysScreenOffTime: Int
screenOffTime =
Settings.System.getInt(contentResolver, Settings.System.SCREEN_OFF_TIMEOUT)
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
return screenOffTime
}
@ -316,7 +317,7 @@ val Context.channel: String
val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
return appInfo.metaData.getString("channel") ?: ""
} catch (e: Exception) {
e.printOnDebug()
Timber.e(e)
}
return ""
}

View File

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

View File

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

View File

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

View File

@ -3,7 +3,6 @@
package io.legado.app.utils
import android.annotation.SuppressLint
import io.legado.app.BuildConfig
import splitties.init.appCtx
import java.text.SimpleDateFormat
import java.util.*
@ -71,12 +70,6 @@ object LogUtils {
}
}
fun Throwable.printOnDebug() {
if (BuildConfig.DEBUG) {
printStackTrace()
}
}
fun dLog(tag: String, msg: String) {
LogUtils.d(tag, msg)
}

View File

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

View File

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

View File

@ -9,6 +9,7 @@ import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
import timber.log.Timber
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
@ -111,7 +112,7 @@ object RealPathUtil {
return cursor.getString(index)
}
} catch (e: IllegalArgumentException) {
e.printOnDebug()
Timber.e(e)
val file = File(context.cacheDir, "tmp")
val filePath = file.absolutePath
var input: FileInputStream? = null
@ -130,7 +131,7 @@ object RealPathUtil {
}
return File(filePath).absolutePath
} catch (ignored: IOException) {
ignored.printOnDebug()
Timber.e(ignored)
} finally {
input?.close()
output?.close()

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ import androidx.viewpager.widget.ViewPager
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.TintHelper
import splitties.init.appCtx
import timber.log.Timber
import java.lang.reflect.Field
@ -171,6 +172,6 @@ fun PopupMenu.show(x: Int, y: Int) {
field.isAccessible = true
(field.get(this) as MenuPopupHelper).show(x, y)
}.onFailure {
it.printOnDebug()
Timber.e(it)
}
}

View File

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

View File

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

View File

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