优化图片下载

pull/352/head
gedoor 4 years ago
parent 5e8a8d152e
commit 17256daf1e
  1. 5
      app/src/main/java/io/legado/app/help/BookHelp.kt

@ -96,6 +96,7 @@ object BookHelp {
} }
downloadImages.add(src) downloadImages.add(src)
val analyzeUrl = AnalyzeUrl(src) val analyzeUrl = AnalyzeUrl(src)
try {
analyzeUrl.getImageBytes(book.origin)?.let { analyzeUrl.getImageBytes(book.origin)?.let {
FileUtils.createFileIfNotExist( FileUtils.createFileIfNotExist(
downloadDir, downloadDir,
@ -105,8 +106,12 @@ object BookHelp {
"${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}" "${MD5Utils.md5Encode16(src)}${getImageSuffix(src)}"
).writeBytes(it) ).writeBytes(it)
} }
} catch (e: Exception) {
e.printStackTrace()
} finally {
downloadImages.remove(src) downloadImages.remove(src)
} }
}
fun getImage(book: Book, src: String): File { fun getImage(book: Book, src: String): File {
return FileUtils.getFile( return FileUtils.getFile(

Loading…
Cancel
Save