mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -45,7 +45,7 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
|
||||
ReadBook.book?.let { book ->
|
||||
src?.let {
|
||||
execute {
|
||||
ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource)
|
||||
ImageProvider.getImage(book, src, ReadBook.bookSource)
|
||||
}.onSuccess { bitmap ->
|
||||
if (bitmap != null) {
|
||||
binding.photoView.setImageBitmap(bitmap)
|
||||
|
||||
@@ -169,7 +169,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
||||
val book = ReadBook.book ?: return
|
||||
ImageProvider.getImage(
|
||||
book,
|
||||
textPage.chapterIndex,
|
||||
textChar.charData,
|
||||
ReadBook.bookSource,
|
||||
true
|
||||
|
||||
@@ -136,7 +136,7 @@ object ChapterProvider {
|
||||
while (matcher.find()) {
|
||||
matcher.group(1)?.let { src ->
|
||||
srcList.add(src)
|
||||
ImageProvider.getImage(book, bookChapter.index, src, ReadBook.bookSource)
|
||||
ImageProvider.getImage(book, src, ReadBook.bookSource)
|
||||
matcher.appendReplacement(sb, srcReplaceChar)
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ object ChapterProvider {
|
||||
}
|
||||
}
|
||||
durY = setTypeImage(
|
||||
book, bookChapter, matcher.group(1)!!,
|
||||
book, matcher.group(1)!!,
|
||||
absStartX, durY, textPages, book.getImageStyle()
|
||||
)
|
||||
start = matcher.end()
|
||||
@@ -202,7 +202,6 @@ object ChapterProvider {
|
||||
|
||||
private fun setTypeImage(
|
||||
book: Book,
|
||||
chapter: BookChapter,
|
||||
src: String,
|
||||
x: Int,
|
||||
y: Float,
|
||||
@@ -210,7 +209,7 @@ object ChapterProvider {
|
||||
imageStyle: String?,
|
||||
): Float {
|
||||
var durY = y
|
||||
ImageProvider.getImage(book, chapter.index, src, ReadBook.bookSource)?.let {
|
||||
ImageProvider.getImage(book, src, ReadBook.bookSource)?.let {
|
||||
if (durY > visibleHeight) {
|
||||
textPages.last().height = durY
|
||||
textPages.add(TextPage())
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
package io.legado.app.ui.book.read.page.provider
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
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.BookSource
|
||||
import io.legado.app.help.BookHelp
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.glide.ImageLoader
|
||||
import io.legado.app.model.localBook.EpubFile
|
||||
import io.legado.app.utils.BitmapUtils
|
||||
import io.legado.app.utils.FileUtils
|
||||
import io.legado.app.R
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import splitties.init.appCtx
|
||||
import java.io.FileOutputStream
|
||||
import java.io.File
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.io.FileOutputStream
|
||||
|
||||
object ImageProvider {
|
||||
|
||||
fun getImage(
|
||||
book: Book,
|
||||
chapterIndex: Int,
|
||||
src: String,
|
||||
bookSource: BookSource?,
|
||||
onUi: Boolean = false,
|
||||
@@ -59,7 +57,11 @@ object ImageProvider {
|
||||
target: Target<Bitmap>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
File(model as String).delete()
|
||||
Coroutine.async {
|
||||
(model as? String)?.let { path ->
|
||||
File(path).delete()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user