Merge pull request #332 from AndyBernie/master

封面链接支持修改headers
pull/341/head
kunfei 4 years ago committed by GitHub
commit 37385d5d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/assets/updateLog.md
  2. 3
      app/src/main/java/io/legado/app/help/ImageLoader.kt
  3. 20
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt

@ -8,6 +8,7 @@
* 修复翻页模式选择颜色问题
* 修复toolbar在一些情况下文字颜色不对的bug
* 多设备阅读记录叠加
* 封面链接支持修改headers
**2020/08/24**
* 应用被杀死时停止朗读

@ -9,6 +9,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.isContentPath
import io.legado.app.model.analyzeRule.AnalyzeUrl
import java.io.File
object ImageLoader {
@ -19,7 +20,7 @@ object ImageLoader {
fun load(context: Context, path: String?): RequestBuilder<Drawable> {
return when {
path.isNullOrEmpty() -> Glide.with(context).load(path)
path.isAbsUrl() -> Glide.with(context).load(path)
path.isAbsUrl() -> Glide.with(context).load(AnalyzeUrl(path).getGlideUrl())
path.isContentPath() -> Glide.with(context).load(Uri.parse(path))
else -> try {
Glide.with(context).load(File(path))

@ -22,7 +22,8 @@ import java.net.URLEncoder
import java.util.*
import java.util.regex.Pattern
import javax.script.SimpleBindings
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.LazyHeaders
/**
* Created by GKF on 2018/1/24.
@ -346,9 +347,7 @@ class AnalyzeUrl(
}
@Throws(Exception::class)
fun getImageBytes(
tag: String
): ByteArray? {
fun getImageBytes(tag: String): ByteArray? {
//资源为本站的资源,保留cookie
//图片盗链的不保留当前的cookie,可由js生成图片源站的cookie
val cookie = CookieStore.getCookie(tag)
@ -403,6 +402,19 @@ class AnalyzeUrl(
return response.body()
}
@Throws(Exception::class)
fun getGlideUrl(): Any? {
var glideUrl: Any = url
if(headerMap.isNotEmpty()) {
val Headers = LazyHeaders.Builder()
headerMap.forEach {(key, value) ->
Headers.addHeader(key, value)
}
glideUrl = GlideUrl(url, Headers.build())
}
return glideUrl
}
data class UrlOption(
val method: String?,
val charset: String?,

@ -69,7 +69,7 @@ class BookInfoEditActivity :
private fun upView(book: Book) {
tie_book_name.setText(book.name)
tie_book_author.setText(book.author)
tie_cover_url.setText(book.getDisplayCover())
tie_cover_url.setText(book.getDisplayCover()?.substringBefore(","))
tie_book_intro.setText(book.getDisplayIntro())
upCover()
}

Loading…
Cancel
Save