|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.model.localBook |
|
|
|
package io.legado.app.model.localBook |
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Bitmap |
|
|
|
import android.graphics.Bitmap |
|
|
|
|
|
|
|
import android.graphics.BitmapFactory |
|
|
|
import android.text.TextUtils |
|
|
|
import android.text.TextUtils |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
@ -84,16 +85,14 @@ class EpubFile(var book: Book) { |
|
|
|
if (!File(book.coverUrl!!).exists()) { |
|
|
|
if (!File(book.coverUrl!!).exists()) { |
|
|
|
/*部分书籍DRM处理后,封面获取异常,待优化*/ |
|
|
|
/*部分书籍DRM处理后,封面获取异常,待优化*/ |
|
|
|
it.coverImage?.inputStream?.use { input -> |
|
|
|
it.coverImage?.inputStream?.use { input -> |
|
|
|
BitmapUtils.decodeBitmap(input)?.let { cover -> |
|
|
|
val cover = BitmapFactory.decodeStream(input) |
|
|
|
val out = |
|
|
|
val out = FileOutputStream(FileUtils.createFileIfNotExist(book.coverUrl!!)) |
|
|
|
FileOutputStream(FileUtils.createFileIfNotExist(book.coverUrl!!)) |
|
|
|
|
|
|
|
cover.compress(Bitmap.CompressFormat.JPEG, 90, out) |
|
|
|
cover.compress(Bitmap.CompressFormat.JPEG, 90, out) |
|
|
|
out.flush() |
|
|
|
out.flush() |
|
|
|
out.close() |
|
|
|
out.close() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
e.printOnDebug() |
|
|
|
e.printOnDebug() |
|
|
|
} |
|
|
|
} |
|
|
|