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