diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-24 17:27:43 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-24 17:27:43 -0500 |
commit | 9e1fe4bb7c692626c9aa336bebcb6c26ca49ea48 (patch) | |
tree | d0c57faea5b3d41101a5510acd951902925485d5 /app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt | |
parent | d12e04e088ce3da967947c955846f76bc73e47a8 (diff) | |
download | frost-9e1fe4bb7c692626c9aa336bebcb6c26ca49ea48.tar.gz frost-9e1fe4bb7c692626c9aa336bebcb6c26ca49ea48.tar.bz2 frost-9e1fe4bb7c692626c9aa336bebcb6c26ca49ea48.zip |
Convert notification service to coroutines
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt index 61a90024..d14c6cd3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt @@ -19,8 +19,9 @@ package com.pitchedapps.frost.utils import android.content.Context import android.text.TextUtils import ca.allanwang.kau.utils.use +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import okhttp3.HttpUrl -import org.jetbrains.anko.doAsync /** * Created by Allan Wang on 2017-09-24. @@ -38,7 +39,7 @@ open class AdBlocker(val assetPath: String) { val data: MutableSet<String> = mutableSetOf() fun init(context: Context) { - doAsync { + GlobalScope.launch { val content = context.assets.open(assetPath).bufferedReader().use { f -> f.readLines().filter { !it.startsWith("#") } } @@ -58,7 +59,7 @@ open class AdBlocker(val assetPath: String) { return false val index = host.indexOf(".") if (index < 0 || index + 1 < host.length) return false - if (host.contains(host)) return true + if (data.contains(host)) return true return isAdHost(host.substring(index + 1)) } } |