pull/540/head
gedoor 4 years ago
parent 54f12baf0f
commit 8d45c9e573
  1. 2
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  2. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  3. 2
      app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  5. 7
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt
  6. 5
      app/src/main/java/io/legado/app/utils/NetworkUtils.kt

@ -63,7 +63,7 @@ data class BookChapter(
fun getAbsoluteURL(): String { fun getAbsoluteURL(): String {
val urlArray = url.split(AnalyzeUrl.splitUrlRegex) val urlArray = url.split(AnalyzeUrl.splitUrlRegex)
var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])!! var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])
if (urlArray.size > 1) { if (urlArray.size > 1) {
absoluteUrl = "$absoluteUrl,${urlArray[1]}" absoluteUrl = "$absoluteUrl,${urlArray[1]}"
} }

@ -165,7 +165,7 @@ class AnalyzeUrl(
*/ */
private fun initUrl() { private fun initUrl() {
var urlArray = ruleUrl.split(splitUrlRegex, 2) var urlArray = ruleUrl.split(splitUrlRegex, 2)
url = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])!! url = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])
urlHasQuery = urlArray[0] urlHasQuery = urlArray[0]
NetworkUtils.getBaseUrl(url)?.let { NetworkUtils.getBaseUrl(url)?.let {
baseUrl = it baseUrl = it

@ -112,7 +112,7 @@ object RssParserByRule {
rssArticle.image = analyzeRule.getString(ruleImage, true) rssArticle.image = analyzeRule.getString(ruleImage, true)
Debug.log(sourceUrl, "${rssArticle.image}", log) Debug.log(sourceUrl, "${rssArticle.image}", log)
Debug.log(sourceUrl, "┌获取文章链接", log) Debug.log(sourceUrl, "┌获取文章链接", log)
rssArticle.link = NetworkUtils.getAbsoluteURL(sourceUrl, analyzeRule.getString(ruleLink))!! rssArticle.link = NetworkUtils.getAbsoluteURL(sourceUrl, analyzeRule.getString(ruleLink))
Debug.log(sourceUrl, "${rssArticle.link}", log) Debug.log(sourceUrl, "${rssArticle.link}", log)
if (rssArticle.title.isBlank()) { if (rssArticle.title.isBlank()) {
return null return null

@ -109,9 +109,8 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
content.split("\n").forEachIndexed { index, text -> content.split("\n").forEachIndexed { index, text ->
val matcher = AppPattern.imgPattern.matcher(text) val matcher = AppPattern.imgPattern.matcher(text)
if (matcher.find()) { if (matcher.find()) {
var src = matcher.group(1) matcher.group(1)?.let {
src = NetworkUtils.getAbsoluteURL(chapter.url, src) val src = NetworkUtils.getAbsoluteURL(chapter.url, it)
src?.let {
srcList.add(Triple(chapter.title, index, src)) srcList.add(Triple(chapter.title, index, src))
} }
} }

@ -95,15 +95,14 @@ object ChapterProvider {
contents.forEachIndexed { index, text -> contents.forEachIndexed { index, text ->
val matcher = AppPattern.imgPattern.matcher(text) val matcher = AppPattern.imgPattern.matcher(text)
if (matcher.find()) { if (matcher.find()) {
var src = matcher.group(1) matcher.group(1)?.let {
if (!book.isEpub()) { if (!book.isEpub()) {
src = NetworkUtils.getAbsoluteURL(bookChapter.url, src) val src = NetworkUtils.getAbsoluteURL(bookChapter.url, it)
}
src?.let {
durY = setTypeImage( durY = setTypeImage(
book, bookChapter, src, durY, textPages, imageStyle book, bookChapter, src, durY, textPages, imageStyle
) )
} }
}
} else { } else {
val isTitle = index == 0 val isTitle = index == 0
val textPaint = if (isTitle) paint.first else paint.second val textPaint = if (isTitle) paint.first else paint.second

@ -69,9 +69,8 @@ object NetworkUtils {
/** /**
* 获取绝对地址 * 获取绝对地址
*/ */
fun getAbsoluteURL(baseURL: String?, relativePath: String?): String? { fun getAbsoluteURL(baseURL: String?, relativePath: String): String {
if (baseURL.isNullOrEmpty()) return relativePath if (baseURL.isNullOrEmpty()) return relativePath
if (relativePath.isNullOrEmpty()) return baseURL
if (relativePath.isAbsUrl()) return relativePath if (relativePath.isAbsUrl()) return relativePath
var relativeUrl = relativePath var relativeUrl = relativePath
try { try {
@ -88,7 +87,7 @@ object NetworkUtils {
/** /**
* 获取绝对地址 * 获取绝对地址
*/ */
fun getAbsoluteURL(baseURL: URL?, relativePath: String): String? { fun getAbsoluteURL(baseURL: URL?, relativePath: String): String {
if (baseURL == null) return relativePath if (baseURL == null) return relativePath
var relativeUrl = relativePath var relativeUrl = relativePath
try { try {

Loading…
Cancel
Save