feat: 优化

This commit is contained in:
kunfei 2020-05-15 17:45:53 +08:00
parent 3166cbd88b
commit 9222c4b73b
3 changed files with 14 additions and 9 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -3,8 +3,9 @@ package io.legado.app.help
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import io.legado.app.App import io.legado.app.App
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.RssSource 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 io.legado.app.utils.splitNotBlank
import org.jetbrains.anko.toast 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 { private fun is18Plus(url: String?): Boolean {
url ?: return false url ?: return false
if (AppConfig.isGooglePlay) return false if (AppConfig.isGooglePlay) return false
list18Plus.forEach { val baseUrl = NetworkUtils.getBaseUrl(url)
if (url.contains(it)) { baseUrl ?: return false
return true 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 return false
} }