pull/913/head
gedoor 4 years ago
parent c0c5cf1188
commit 48b5320981
  1. 8
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  2. 6
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -26,15 +26,15 @@ import java.util.*
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
class EPUBFile(var book: Book) {
class EpubFile(var book: Book) {
companion object {
private var eFile: EPUBFile? = null
private var eFile: EpubFile? = null
@Synchronized
private fun getEFile(book: Book): EPUBFile {
private fun getEFile(book: Book): EpubFile {
if (eFile == null || eFile?.book?.bookUrl != book.bookUrl) {
eFile = EPUBFile(book)
eFile = EpubFile(book)
return eFile!!
}
eFile?.book = book

@ -22,7 +22,7 @@ object LocalBook {
fun getChapterList(book: Book): ArrayList<BookChapter> {
return if (book.isEpub()) {
EPUBFile.getChapterList(book)
EpubFile.getChapterList(book)
} else {
AnalyzeTxtFile().analyze(book)
}
@ -30,7 +30,7 @@ object LocalBook {
fun getContext(book: Book, chapter: BookChapter): String? {
return if (book.isEpub()) {
EPUBFile.getContent(book, chapter)
EpubFile.getContent(book, chapter)
} else {
AnalyzeTxtFile.getContent(book, chapter)
}
@ -83,7 +83,7 @@ object LocalBook {
"${MD5Utils.md5Encode16(path)}.jpg"
)
)
if (book.isEpub()) EPUBFile.upBookInfo(book)
if (book.isEpub()) EpubFile.upBookInfo(book)
appDb.bookDao.insert(book)
return book
}

@ -3,7 +3,7 @@ package io.legado.app.ui.book.read.page.provider
import android.graphics.Bitmap
import io.legado.app.data.entities.Book
import io.legado.app.help.BookHelp
import io.legado.app.model.localBook.EPUBFile
import io.legado.app.model.localBook.EpubFile
import io.legado.app.utils.BitmapUtils
import io.legado.app.utils.FileUtils
import kotlinx.coroutines.runBlocking
@ -36,7 +36,7 @@ object ImageProvider {
val vFile = BookHelp.getImage(book, src)
if (!vFile.exists()) {
if (book.isEpub()) {
EPUBFile.getImage(book, src)?.use { input ->
EpubFile.getImage(book, src)?.use { input ->
val newFile = FileUtils.createFileIfNotExist(vFile.absolutePath)
FileOutputStream(newFile).use { output ->
input.copyTo(output)

Loading…
Cancel
Save