fix:搜索封面,详情封面,封面换源的缺省headers的优先级:书源>全局

pull/1766/head
Xwite 3 years ago
parent 27c31bf0c0
commit 3f49ef95ff
  1. 6
      app/src/main/java/io/legado/app/help/glide/ImageLoader.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  5. 5
      app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt

@ -7,6 +7,7 @@ import android.net.Uri
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestBuilder
import io.legado.app.constant.AppPattern.dataUriRegex import io.legado.app.constant.AppPattern.dataUriRegex
import io.legado.app.data.appDb
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.isContentScheme import io.legado.app.utils.isContentScheme
@ -18,7 +19,7 @@ object ImageLoader {
/** /**
* 自动判断path类型 * 自动判断path类型
*/ */
fun load(context: Context, path: String?): RequestBuilder<Drawable> { fun load(context: Context, path: String?, sourceOrigin: String? = null): RequestBuilder<Drawable> {
return when { return when {
path.isNullOrEmpty() -> GlideApp.with(context).load(path) path.isNullOrEmpty() -> GlideApp.with(context).load(path)
dataUriRegex.find(path) != null -> { dataUriRegex.find(path) != null -> {
@ -27,7 +28,8 @@ object ImageLoader {
} }
path.isAbsUrl() -> { path.isAbsUrl() -> {
kotlin.runCatching { kotlin.runCatching {
val url = AnalyzeUrl(path).getGlideUrl() val source = sourceOrigin?.let { appDb.bookSourceDao.getBookSource(it) }
val url = AnalyzeUrl(path, source = source).getGlideUrl()
GlideApp.with(context).load(url) GlideApp.with(context).load(url)
}.getOrDefault( }.getOrDefault(
GlideApp.with(context).load(path) GlideApp.with(context).load(path)

@ -35,7 +35,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) :
item: SearchBook, item: SearchBook,
payloads: MutableList<Any> payloads: MutableList<Any>
) = binding.run { ) = binding.run {
ivCover.load(item.coverUrl, item.name, item.author) ivCover.load(item.coverUrl, item.name, item.author, false, item.origin)
tvSource.text = item.originName tvSource.text = item.originName
} }

@ -220,7 +220,7 @@ class BookInfoActivity :
} }
private fun showCover(book: Book) { private fun showCover(book: Book) {
binding.ivCover.load(book.getDisplayCover(), book.name, book.author) binding.ivCover.load(book.getDisplayCover(), book.name, book.author, false, book.origin)
BookCover.loadBlur(this, book.getDisplayCover()) BookCover.loadBlur(this, book.getDisplayCover())
.into(binding.bgBook) .into(binding.bgBook)
} }

@ -86,7 +86,8 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
searchBook.coverUrl, searchBook.coverUrl,
searchBook.name, searchBook.name,
searchBook.author, searchBook.author,
AppConfig.loadOnlyWifi AppConfig.loadOnlyWifi,
searchBook.origin
) )
} }
} }
@ -99,7 +100,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
"last" -> upLasted(binding, searchBook.latestChapterTitle) "last" -> upLasted(binding, searchBook.latestChapterTitle)
"intro" -> tvIntroduce.text = searchBook.trimIntro(context) "intro" -> tvIntroduce.text = searchBook.trimIntro(context)
"kind" -> upKind(binding, searchBook.getKindList()) "kind" -> upKind(binding, searchBook.getKindList())
"cover" -> ivCover.load(searchBook.coverUrl, searchBook.name, searchBook.author) "cover" -> ivCover.load(searchBook.coverUrl, searchBook.name, searchBook.author, false, searchBook.origin)
} }
} }
} }

@ -175,7 +175,8 @@ class CoverImageView @JvmOverloads constructor(
path: String? = null, path: String? = null,
name: String? = null, name: String? = null,
author: String? = null, author: String? = null,
loadOnlyWifi: Boolean = false loadOnlyWifi: Boolean = false,
sourceOrigin: String? = null
) { ) {
this.bitmapPath = path this.bitmapPath = path
this.name = name?.replace(AppPattern.bdRegex, "")?.trim() this.name = name?.replace(AppPattern.bdRegex, "")?.trim()
@ -186,7 +187,7 @@ class CoverImageView @JvmOverloads constructor(
.centerCrop() .centerCrop()
.into(this) .into(this)
} else { } else {
ImageLoader.load(context, path)//Glide自动识别http://,content://和file:// ImageLoader.load(context, path, sourceOrigin)//Glide自动识别http://,content://和file://
.apply(RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi)) .apply(RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi))
.placeholder(BookCover.defaultDrawable) .placeholder(BookCover.defaultDrawable)
.error(BookCover.defaultDrawable) .error(BookCover.defaultDrawable)

Loading…
Cancel
Save