From 3f49ef95ffb2b70891256ee2c0beffa91b9745bb Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sun, 10 Apr 2022 18:48:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=90=9C=E7=B4=A2=E5=B0=81=E9=9D=A2,?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=B0=81=E9=9D=A2,=E5=B0=81=E9=9D=A2?= =?UTF-8?q?=E6=8D=A2=E6=BA=90=E7=9A=84=E7=BC=BA=E7=9C=81headers=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=85=88=E7=BA=A7:=E4=B9=A6=E6=BA=90>=E5=85=A8?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/glide/ImageLoader.kt | 6 ++++-- .../java/io/legado/app/ui/book/changecover/CoverAdapter.kt | 2 +- .../java/io/legado/app/ui/book/info/BookInfoActivity.kt | 2 +- .../main/java/io/legado/app/ui/book/search/SearchAdapter.kt | 5 +++-- .../java/io/legado/app/ui/widget/image/CoverImageView.kt | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt b/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt index aca00cd6a..ea4163da4 100644 --- a/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt +++ b/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt @@ -7,6 +7,7 @@ import android.net.Uri import androidx.annotation.DrawableRes import com.bumptech.glide.RequestBuilder import io.legado.app.constant.AppPattern.dataUriRegex +import io.legado.app.data.appDb import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isContentScheme @@ -18,7 +19,7 @@ object ImageLoader { /** * 自动判断path类型 */ - fun load(context: Context, path: String?): RequestBuilder { + fun load(context: Context, path: String?, sourceOrigin: String? = null): RequestBuilder { return when { path.isNullOrEmpty() -> GlideApp.with(context).load(path) dataUriRegex.find(path) != null -> { @@ -27,7 +28,8 @@ object ImageLoader { } path.isAbsUrl() -> { 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) }.getOrDefault( GlideApp.with(context).load(path) diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt index 323dbfc05..92b90ac94 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt @@ -35,7 +35,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) : item: SearchBook, payloads: MutableList ) = 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 } diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 9cf8fa8f5..cac6831f6 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -220,7 +220,7 @@ class BookInfoActivity : } 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()) .into(binding.bgBook) } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index 7e4146a4c..f31dea1ff 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -86,7 +86,8 @@ class SearchAdapter(context: Context, val callBack: CallBack) : searchBook.coverUrl, searchBook.name, searchBook.author, - AppConfig.loadOnlyWifi + AppConfig.loadOnlyWifi, + searchBook.origin ) } } @@ -99,7 +100,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : "last" -> upLasted(binding, searchBook.latestChapterTitle) "intro" -> tvIntroduce.text = searchBook.trimIntro(context) "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) } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 61b0baebe..995b1a120 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -175,7 +175,8 @@ class CoverImageView @JvmOverloads constructor( path: String? = null, name: String? = null, author: String? = null, - loadOnlyWifi: Boolean = false + loadOnlyWifi: Boolean = false, + sourceOrigin: String? = null ) { this.bitmapPath = path this.name = name?.replace(AppPattern.bdRegex, "")?.trim() @@ -186,7 +187,7 @@ class CoverImageView @JvmOverloads constructor( .centerCrop() .into(this) } else { - ImageLoader.load(context, path)//Glide自动识别http://,content://和file:// + ImageLoader.load(context, path, sourceOrigin)//Glide自动识别http://,content://和file:// .apply(RequestOptions().set(OkHttpModelLoader.loadOnlyWifiOption, loadOnlyWifi)) .placeholder(BookCover.defaultDrawable) .error(BookCover.defaultDrawable)