feat: 优化

pull/219/head
kunfei 5 years ago
parent 3166cbd88b
commit 9222c4b73b
  1. 1
      .gitignore
  2. 2
      app/src/main/assets/18PlusList.txt
  3. 20
      app/src/main/java/io/legado/app/help/SourceHelp.kt

1
.gitignore vendored

@ -13,4 +13,3 @@ node_modules/
/app/google
/app/gradle.properties
package-lock.json
18PlusList.txt

@ -0,0 +1,2 @@
OGN5dS5jb20=
c2cwMC54eXo=

@ -3,8 +3,9 @@ package io.legado.app.help
import android.os.Handler
import android.os.Looper
import io.legado.app.App
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.RssSource
import io.legado.app.utils.EncoderUtils
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.splitNotBlank
import org.jetbrains.anko.toast
@ -32,17 +33,20 @@ object SourceHelp {
}
}
fun insertBookSource(vararg bookSources: BookSource) {
App.db.bookSourceDao().insert(*bookSources)
}
private fun is18Plus(url: String?): Boolean {
url ?: return false
if (AppConfig.isGooglePlay) return false
list18Plus.forEach {
if (url.contains(it)) {
return true
val baseUrl = NetworkUtils.getBaseUrl(url)
baseUrl ?: return false
try {
val host = baseUrl.split("//", ".")
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}")
list18Plus.forEach {
if (base64Url == it) {
return true
}
}
} catch (e: Exception) {
}
return false
}

Loading…
Cancel
Save