mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
feat: 优化
This commit is contained in:
parent
3166cbd88b
commit
9222c4b73b
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,4 +13,3 @@ node_modules/
|
||||
/app/google
|
||||
/app/gradle.properties
|
||||
package-lock.json
|
||||
18PlusList.txt
|
||||
|
2
app/src/main/assets/18PlusList.txt
Normal file
2
app/src/main/assets/18PlusList.txt
Normal file
@ -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…
Reference in New Issue
Block a user