更换默认封面,去除封面文字

pull/1319/head
gedoor 3 years ago
parent 5bcf3fcd00
commit f1788ed904
  1. 24
      app/src/main/java/io/legado/app/constant/AppLog.kt
  2. 20
      app/src/main/java/io/legado/app/model/CacheBook.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt

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

@ -1,7 +1,7 @@
package io.legado.app.model
import android.annotation.SuppressLint
import android.content.Context
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus
import io.legado.app.constant.IntentAction
import io.legado.app.data.appDb
@ -15,8 +15,6 @@ import io.legado.app.utils.postEvent
import io.legado.app.utils.startService
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import kotlin.coroutines.CoroutineContext
@ -24,12 +22,8 @@ class CacheBook(var bookSource: BookSource, var book: Book) {
companion object {
val logs = arrayListOf<String>()
val cacheBookMap = ConcurrentHashMap<String, CacheBook>()
@SuppressLint("ConstantLocale")
private val logTimeFormat = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault())
@Synchronized
fun getOrCreate(bookUrl: String): CacheBook? {
val book = appDb.bookDao.getBook(bookUrl) ?: return null
@ -60,16 +54,6 @@ class CacheBook(var bookSource: BookSource, var book: Book) {
return cacheBook
}
fun addLog(log: String?) {
log ?: return
synchronized(logs) {
if (logs.size > 1000) {
logs.removeLastOrNull()
}
logs.add(0, logTimeFormat.format(Date()) + " " + log)
}
}
fun start(context: Context, bookUrl: String, start: Int, end: Int) {
context.startService<CacheBookService> {
action = IntentAction.start
@ -185,7 +169,7 @@ class CacheBook(var bookSource: BookSource, var book: Book) {
if (errorDownloadMap[index] ?: 0 < 3) {
waitDownloadSet.add(index)
} else {
addLog("${book.name}-${chapterTitle} ${error.localizedMessage}")
AppLog.addLog("${book.name}-${chapterTitle} ${error.localizedMessage}")
}
}

@ -11,6 +11,7 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppConst.charsets
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
@ -136,7 +137,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
R.id.menu_export_type -> showExportTypeConfig()
R.id.menu_export_charset -> showCharsetConfig()
R.id.menu_log ->
TextListDialog.show(supportFragmentManager, getString(R.string.log), CacheBook.logs)
TextListDialog.show(supportFragmentManager, getString(R.string.log), AppLog.logs)
else -> if (item.groupId == R.id.menu_group) {
binding.titleBar.subtitle = item.title
groupId = appDb.bookGroupDao.getByName(item.title.toString())?.groupId ?: 0

Loading…
Cancel
Save