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!!,
textPage.chapterIndex,
textChar.charData,
textChar.charData,
true
)?.let {
canvas.drawBitmap(it, null, rectF, null)

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

@ -31,7 +31,7 @@ object ImageProvider {
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 {
return it
}
@ -49,7 +49,7 @@ object ImageProvider {
out.close()
}
} else if (!onUi) {
HttpHelper.getBytes(src, src)?.let {
HttpHelper.getBytes(src, baseUrl)?.let {
FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it)
}
}

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

Loading…
Cancel
Save