Merge pull request #314 from AndyBernie/patch-1

修复baseUrl未定义
pull/315/head
kunfei 4 years ago committed by GitHub
commit e3cddfc40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt
  4. 2
      app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt

@ -163,6 +163,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
ReadBook.book!!, ReadBook.book!!,
textPage.chapterIndex, textPage.chapterIndex,
textChar.charData, textChar.charData,
textChar.charData,
true true
)?.let { )?.let {
canvas.drawBitmap(it, null, rectF, null) canvas.drawBitmap(it, null, rectF, null)

@ -122,7 +122,7 @@ object ChapterProvider {
imageStyle: String? imageStyle: String?
): Float { ): Float {
var durY = y var durY = y
ImageProvider.getImage(book, chapter.index, src)?.let { ImageProvider.getImage(book, chapter.index, src, chapter.url)?.let {
if (durY > visibleHeight) { if (durY > visibleHeight) {
textPages.last().height = durY textPages.last().height = durY
textPages.add(TextPage()) textPages.add(TextPage())
@ -453,4 +453,4 @@ object ChapterProvider {
val TextPaint.textHeight: Float val TextPaint.textHeight: Float
get() = fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading get() = fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading
} }

@ -31,7 +31,7 @@ object ImageProvider {
indexCache[src] = bitmap indexCache[src] = bitmap
} }
fun getImage(book: Book, chapterIndex: Int, src: String, onUi: Boolean = false): Bitmap? { fun getImage(book: Book, chapterIndex: Int, src: String, baseUrl: String, onUi: Boolean = false): Bitmap? {
getCache(chapterIndex, src)?.let { getCache(chapterIndex, src)?.let {
return it return it
} }
@ -49,7 +49,7 @@ object ImageProvider {
out.close() out.close()
} }
} else if (!onUi) { } else if (!onUi) {
HttpHelper.getBytes(src, src)?.let { HttpHelper.getBytes(src, baseUrl)?.let {
FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it) FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it)
} }
} }

@ -56,7 +56,7 @@ class PhotoDialog : BaseDialogFragment() {
val src = it.getString("src") val src = it.getString("src")
ReadBook.book?.let { book -> ReadBook.book?.let { book ->
src?.let { src?.let {
ImageProvider.getImage(book, chapterIndex, src)?.let { bitmap -> ImageProvider.getImage(book, chapterIndex, src, src)?.let { bitmap ->
photo_view.setImageBitmap(bitmap) photo_view.setImageBitmap(bitmap)
} }
} }

Loading…
Cancel
Save