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 {
val urlArray = url.split(AnalyzeUrl.splitUrlRegex)
var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])!!
var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])
if (urlArray.size > 1) {
absoluteUrl = "$absoluteUrl,${urlArray[1]}"
}

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

@ -112,7 +112,7 @@ object RssParserByRule {
rssArticle.image = analyzeRule.getString(ruleImage, true)
Debug.log(sourceUrl, "${rssArticle.image}", 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)
if (rssArticle.title.isBlank()) {
return null

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

@ -95,15 +95,14 @@ object ChapterProvider {
contents.forEachIndexed { index, text ->
val matcher = AppPattern.imgPattern.matcher(text)
if (matcher.find()) {
var src = matcher.group(1)
matcher.group(1)?.let {
if (!book.isEpub()) {
src = NetworkUtils.getAbsoluteURL(bookChapter.url, src)
}
src?.let {
val src = NetworkUtils.getAbsoluteURL(bookChapter.url, it)
durY = setTypeImage(
book, bookChapter, src, durY, textPages, imageStyle
)
}
}
} else {
val isTitle = index == 0
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 (relativePath.isNullOrEmpty()) return baseURL
if (relativePath.isAbsUrl()) return relativePath
var relativeUrl = relativePath
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
var relativeUrl = relativePath
try {

Loading…
Cancel
Save