mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
4655e69d12
commit
298a824d0c
@ -73,8 +73,8 @@ object BookHelp {
|
||||
*/
|
||||
suspend fun clearInvalidCache() {
|
||||
withContext(IO) {
|
||||
val bookFolderNames = ArrayList<String>()
|
||||
val originNames = ArrayList<String>()
|
||||
val bookFolderNames = hashSetOf<String>()
|
||||
val originNames = hashSetOf<String>()
|
||||
appDb.bookDao.all.forEach {
|
||||
bookFolderNames.add(it.getFolderName())
|
||||
if (it.isEpub) originNames.add(it.originName)
|
||||
@ -260,7 +260,9 @@ object BookHelp {
|
||||
* 检测该章节是否下载
|
||||
*/
|
||||
fun hasContent(book: Book, bookChapter: BookChapter): Boolean {
|
||||
return if (book.isLocalTxt) {
|
||||
return if (book.isLocalTxt
|
||||
|| (bookChapter.isVolume && bookChapter.url.startsWith(bookChapter.title))
|
||||
) {
|
||||
true
|
||||
} else {
|
||||
downloadDir.exists(
|
||||
@ -290,11 +292,11 @@ object BookHelp {
|
||||
ret = false
|
||||
continue
|
||||
}
|
||||
BitmapFactory.decodeFile(image.absolutePath, op)
|
||||
if (op.outWidth < 1 && op.outHeight < 1) {
|
||||
if (SvgUtils.getSize(image.absolutePath) != null) {
|
||||
continue
|
||||
}
|
||||
BitmapFactory.decodeFile(image.absolutePath, op)
|
||||
if (op.outWidth < 1 && op.outHeight < 1) {
|
||||
ret = false
|
||||
image.delete()
|
||||
}
|
||||
@ -304,14 +306,11 @@ object BookHelp {
|
||||
}
|
||||
|
||||
private fun checkImage(bytes: ByteArray): Boolean {
|
||||
if (SvgUtils.getSize(ByteArrayInputStream(bytes)) != null) {
|
||||
return true
|
||||
}
|
||||
val op = BitmapFactory.Options()
|
||||
op.inJustDecodeBounds = true
|
||||
BitmapFactory.decodeByteArray(bytes, 0, bytes.size, op)
|
||||
if (op.outWidth < 1 && op.outHeight < 1) {
|
||||
return false
|
||||
return SvgUtils.getSize(ByteArrayInputStream(bytes)) != null
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -488,7 +487,6 @@ object BookHelp {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
private val regexOther by lazy {
|
||||
// 所有非字母数字中日韩文字 CJK区+扩展A-F区
|
||||
@Suppress("RegExpDuplicateCharacterInClass")
|
||||
|
Loading…
Reference in New Issue
Block a user