@@ -51,8 +51,17 @@ java.put(key, value)
|
|||||||
```
|
```
|
||||||
* 网络请求
|
* 网络请求
|
||||||
```
|
```
|
||||||
java.ajax(urlStr)
|
java.ajax(urlStr): String
|
||||||
java.ajaxAll(urlList: Array<String>): Array<StrResponse?>
|
java.ajaxAll(urlList: Array<String>): Array<StrResponse?>
|
||||||
|
//返回Response 方法body() code() message() header() raw() toString()
|
||||||
|
java.connect(urlStr): Response<String>
|
||||||
|
|
||||||
|
* 使用webView访问网络
|
||||||
|
* @param html 直接用webView载入的html, 如果html为空直接访问url
|
||||||
|
* @param url html内如果有相对路径的资源不传入url访问不了
|
||||||
|
* @param js 用来取返回值的js语句, 没有就返回整个源代码
|
||||||
|
* @return 返回js获取的内容
|
||||||
|
java.webView(html: String?, url: String?, js: String?): String
|
||||||
```
|
```
|
||||||
* 调试
|
* 调试
|
||||||
```
|
```
|
||||||
@@ -142,7 +151,8 @@ java.md5Encode(str)
|
|||||||
java.md5Encode16(str)
|
java.md5Encode16(str)
|
||||||
```
|
```
|
||||||
|
|
||||||
## book对象的可用属性
|
## book对象的可用属性和方法
|
||||||
|
### 属性
|
||||||
> 使用方法: 在js中或{{}}中使用book.属性的方式即可获取.如在正文内容后加上 ##{{book.name+"正文卷"+title}} 可以净化 书名+正文卷+章节名称(如 我是大明星正文卷第二章我爸是豪门总裁) 这一类的字符.
|
> 使用方法: 在js中或{{}}中使用book.属性的方式即可获取.如在正文内容后加上 ##{{book.name+"正文卷"+title}} 可以净化 书名+正文卷+章节名称(如 我是大明星正文卷第二章我爸是豪门总裁) 这一类的字符.
|
||||||
```
|
```
|
||||||
bookUrl // 详情页Url(本地书源存储完整文件路径)
|
bookUrl // 详情页Url(本地书源存储完整文件路径)
|
||||||
@@ -174,6 +184,11 @@ order // 手动排序
|
|||||||
originOrder //书源排序
|
originOrder //书源排序
|
||||||
variable // 自定义书籍变量信息(用于书源规则检索书籍信息)
|
variable // 自定义书籍变量信息(用于书源规则检索书籍信息)
|
||||||
```
|
```
|
||||||
|
### 方法
|
||||||
|
```
|
||||||
|
//可在正文js中关闭净化 对于漫画源有用
|
||||||
|
book.setUseReplaceRule(boolean)
|
||||||
|
```
|
||||||
|
|
||||||
## chapter对象的部分可用属性
|
## chapter对象的部分可用属性
|
||||||
> 使用方法: 在js中或{{}}中使用chapter.属性的方式即可获取.如在正文内容后加上 ##{{chapter.title+chapter.index}} 可以净化 章节标题+序号(如 第二章 天仙下凡2) 这一类的字符.
|
> 使用方法: 在js中或{{}}中使用chapter.属性的方式即可获取.如在正文内容后加上 ##{{chapter.title+chapter.index}} 可以净化 章节标题+序号(如 第二章 天仙下凡2) 这一类的字符.
|
||||||
|
|||||||
@@ -123,7 +123,9 @@ interface JsExtensions {
|
|||||||
BackstageWebView(
|
BackstageWebView(
|
||||||
url = url,
|
url = url,
|
||||||
html = html,
|
html = html,
|
||||||
javaScript = js
|
javaScript = js,
|
||||||
|
headerMap = getSource()?.getHeaderMap(true),
|
||||||
|
tag = getSource()?.getKey()
|
||||||
).getStrResponse().body
|
).getStrResponse().body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,10 @@ object ImageLoader {
|
|||||||
}
|
}
|
||||||
path.isAbsUrl() -> {
|
path.isAbsUrl() -> {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
val url = AnalyzeUrl(path).getGlideUrl()
|
val source = sourceOrigin?.let {
|
||||||
|
appDb.bookSourceDao.getBookSource(it) ?: appDb.rssSourceDao.getByKey(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)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class AnalyzeUrl(
|
|||||||
init {
|
init {
|
||||||
val urlMatcher = paramPattern.matcher(baseUrl)
|
val urlMatcher = paramPattern.matcher(baseUrl)
|
||||||
if (urlMatcher.find()) baseUrl = baseUrl.substring(0, urlMatcher.start())
|
if (urlMatcher.find()) baseUrl = baseUrl.substring(0, urlMatcher.start())
|
||||||
headerMapF?.let {
|
(headerMapF ?: source?.getHeaderMap(true))?.let {
|
||||||
headerMap.putAll(it)
|
headerMap.putAll(it)
|
||||||
if (it.containsKey("proxy")) {
|
if (it.containsKey("proxy")) {
|
||||||
proxy = it["proxy"]
|
proxy = it["proxy"]
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
|
|||||||
llKind.visible()
|
llKind.visible()
|
||||||
llKind.setLabels(kinds)
|
llKind.setLabels(kinds)
|
||||||
}
|
}
|
||||||
ivCover.load(item.coverUrl, item.name, item.author, AppConfig.loadOnlyWifi)
|
ivCover.load(item.coverUrl, item.name, item.author, AppConfig.loadOnlyWifi, item.origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
|
|||||||
val bundle = payloads.getOrNull(0) as? Bundle
|
val bundle = payloads.getOrNull(0) as? Bundle
|
||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
upRefresh(binding, item)
|
upRefresh(binding, item)
|
||||||
} else {
|
} else {
|
||||||
bundle.keySet().forEach {
|
bundle.keySet().forEach {
|
||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvName.text = item.name
|
"name" -> tvName.text = item.name
|
||||||
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author)
|
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
"refresh" -> upRefresh(binding, item)
|
"refresh" -> upRefresh(binding, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
|
|||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvRead.text = item.durChapterTitle
|
tvRead.text = item.durChapterTitle
|
||||||
tvLast.text = item.latestChapterTitle
|
tvLast.text = item.latestChapterTitle
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
upRefresh(binding, item)
|
upRefresh(binding, item)
|
||||||
} else {
|
} else {
|
||||||
tvRead.text = item.durChapterTitle
|
tvRead.text = item.durChapterTitle
|
||||||
@@ -39,7 +39,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
|
|||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvName.text = item.name
|
"name" -> tvName.text = item.name
|
||||||
"author" -> tvAuthor.text = item.author
|
"author" -> tvAuthor.text = item.author
|
||||||
"cover" -> ivCover.load(item.getDisplayCover())
|
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
"refresh" -> upRefresh(binding, item)
|
"refresh" -> upRefresh(binding, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
|
|||||||
bundle.keySet().forEach {
|
bundle.keySet().forEach {
|
||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvName.text = item.name
|
"name" -> tvName.text = item.name
|
||||||
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author)
|
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
"refresh" -> upRefresh(this, item)
|
"refresh" -> upRefresh(this, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) :
|
|||||||
val item = callBack.getItem(position)
|
val item = callBack.getItem(position)
|
||||||
if (item is Book) {
|
if (item is Book) {
|
||||||
tvName.text = item.name
|
tvName.text = item.name
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
upRefresh(this, item)
|
upRefresh(this, item)
|
||||||
}
|
}
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
|
|||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvName.text = item.name
|
"name" -> tvName.text = item.name
|
||||||
"author" -> tvAuthor.text = item.author
|
"author" -> tvAuthor.text = item.author
|
||||||
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author)
|
"cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
"refresh" -> upRefresh(this, item)
|
"refresh" -> upRefresh(this, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ class BooksAdapterList(context: Context, callBack: CallBack) :
|
|||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvRead.text = item.durChapterTitle
|
tvRead.text = item.durChapterTitle
|
||||||
tvLast.text = item.latestChapterTitle
|
tvLast.text = item.latestChapterTitle
|
||||||
ivCover.load(item.getDisplayCover(), item.name, item.author)
|
ivCover.load(item.getDisplayCover(), item.name, item.author, false, item.origin)
|
||||||
flHasNew.visible()
|
flHasNew.visible()
|
||||||
ivAuthor.visible()
|
ivAuthor.visible()
|
||||||
ivLast.visible()
|
ivLast.visible()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class RssAdapter(context: Context, val callBack: CallBack) :
|
|||||||
) {
|
) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
tvName.text = item.sourceName
|
tvName.text = item.sourceName
|
||||||
ImageLoader.load(context, item.sourceIcon)
|
ImageLoader.load(context, item.sourceIcon, item.sourceUrl)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.placeholder(R.drawable.image_rss)
|
.placeholder(R.drawable.image_rss)
|
||||||
.error(R.drawable.image_rss)
|
.error(R.drawable.image_rss)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
|
|||||||
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
||||||
imageView.gone()
|
imageView.gone()
|
||||||
} else {
|
} else {
|
||||||
ImageLoader.load(context, item.image).apply {
|
ImageLoader.load(context, item.image, item.origin).apply {
|
||||||
if (callBack.isGridLayout) {
|
if (callBack.isGridLayout) {
|
||||||
placeholder(R.drawable.image_rss_article)
|
placeholder(R.drawable.image_rss_article)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RssArticlesAdapter1(context: Context, callBack: CallBack) :
|
|||||||
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
||||||
imageView.gone()
|
imageView.gone()
|
||||||
} else {
|
} else {
|
||||||
ImageLoader.load(context, item.image).apply {
|
ImageLoader.load(context, item.image, item.origin).apply {
|
||||||
if (callBack.isGridLayout) {
|
if (callBack.isGridLayout) {
|
||||||
placeholder(R.drawable.image_rss_article)
|
placeholder(R.drawable.image_rss_article)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RssArticlesAdapter2(context: Context, callBack: CallBack) :
|
|||||||
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
if (item.image.isNullOrBlank() && !callBack.isGridLayout) {
|
||||||
imageView.gone()
|
imageView.gone()
|
||||||
} else {
|
} else {
|
||||||
ImageLoader.load(context, item.image).apply {
|
ImageLoader.load(context, item.image, item.origin).apply {
|
||||||
if (callBack.isGridLayout) {
|
if (callBack.isGridLayout) {
|
||||||
placeholder(R.drawable.image_rss_article)
|
placeholder(R.drawable.image_rss_article)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class RssFavoritesAdapter(context: Context, val callBack: CallBack) :
|
|||||||
if (item.image.isNullOrBlank()) {
|
if (item.image.isNullOrBlank()) {
|
||||||
imageView.gone()
|
imageView.gone()
|
||||||
} else {
|
} else {
|
||||||
ImageLoader.load(context, item.image)
|
ImageLoader.load(context, item.image, item.origin)
|
||||||
.addListener(object : RequestListener<Drawable> {
|
.addListener(object : RequestListener<Drawable> {
|
||||||
override fun onLoadFailed(
|
override fun onLoadFailed(
|
||||||
e: GlideException?,
|
e: GlideException?,
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user