pull/1776/head
kunfei 3 years ago
parent 1ec7dd1981
commit db99dd6deb
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt
  2. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt
  4. 16
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -45,7 +45,7 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
ReadBook.book?.let { book -> ReadBook.book?.let { book ->
src?.let { src?.let {
execute { execute {
ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource) ImageProvider.getImage(book, src, ReadBook.bookSource)
}.onSuccess { bitmap -> }.onSuccess { bitmap ->
if (bitmap != null) { if (bitmap != null) {
binding.photoView.setImageBitmap(bitmap) binding.photoView.setImageBitmap(bitmap)

@ -169,7 +169,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
val book = ReadBook.book ?: return val book = ReadBook.book ?: return
ImageProvider.getImage( ImageProvider.getImage(
book, book,
textPage.chapterIndex,
textChar.charData, textChar.charData,
ReadBook.bookSource, ReadBook.bookSource,
true true

@ -136,7 +136,7 @@ object ChapterProvider {
while (matcher.find()) { while (matcher.find()) {
matcher.group(1)?.let { src -> matcher.group(1)?.let { src ->
srcList.add(src) srcList.add(src)
ImageProvider.getImage(book, bookChapter.index, src, ReadBook.bookSource) ImageProvider.getImage(book, src, ReadBook.bookSource)
matcher.appendReplacement(sb, srcReplaceChar) matcher.appendReplacement(sb, srcReplaceChar)
} }
} }
@ -163,7 +163,7 @@ object ChapterProvider {
} }
} }
durY = setTypeImage( durY = setTypeImage(
book, bookChapter, matcher.group(1)!!, book, matcher.group(1)!!,
absStartX, durY, textPages, book.getImageStyle() absStartX, durY, textPages, book.getImageStyle()
) )
start = matcher.end() start = matcher.end()
@ -202,7 +202,6 @@ object ChapterProvider {
private fun setTypeImage( private fun setTypeImage(
book: Book, book: Book,
chapter: BookChapter,
src: String, src: String,
x: Int, x: Int,
y: Float, y: Float,
@ -210,7 +209,7 @@ object ChapterProvider {
imageStyle: String?, imageStyle: String?,
): Float { ): Float {
var durY = y var durY = y
ImageProvider.getImage(book, chapter.index, src, ReadBook.bookSource)?.let { ImageProvider.getImage(book, src, ReadBook.bookSource)?.let {
if (durY > visibleHeight) { if (durY > visibleHeight) {
textPages.last().height = durY textPages.last().height = durY
textPages.add(TextPage()) textPages.add(TextPage())

@ -1,29 +1,27 @@
package io.legado.app.ui.book.read.page.provider package io.legado.app.ui.book.read.page.provider
import android.graphics.Bitmap import android.graphics.Bitmap
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target import com.bumptech.glide.request.target.Target
import io.legado.app.R
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.glide.ImageLoader import io.legado.app.help.glide.ImageLoader
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 io.legado.app.utils.FileUtils
import io.legado.app.R
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import splitties.init.appCtx import splitties.init.appCtx
import java.io.FileOutputStream
import java.io.File import java.io.File
import java.util.concurrent.ConcurrentHashMap import java.io.FileOutputStream
object ImageProvider { object ImageProvider {
fun getImage( fun getImage(
book: Book, book: Book,
chapterIndex: Int,
src: String, src: String,
bookSource: BookSource?, bookSource: BookSource?,
onUi: Boolean = false, onUi: Boolean = false,
@ -59,7 +57,11 @@ object ImageProvider {
target: Target<Bitmap>?, target: Target<Bitmap>?,
isFirstResource: Boolean isFirstResource: Boolean
): Boolean { ): Boolean {
File(model as String).delete() Coroutine.async {
(model as? String)?.let { path ->
File(path).delete()
}
}
return false return false
} }

Loading…
Cancel
Save