Singletonize EhProxySelector
This commit is contained in:
1 parent
58d1ace612
commit
b5baecf8d0
3 files changed
+7
-12
No files matched your search
@@ -138,13 +138,11 @@ class EhApplication : Application(), ImageLoaderFactory {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ehProxySelector by lazy { EhProxySelector() }
|
||||
|
||||
val nonCacheOkHttpClient by lazy {
|
||||
httpClient {
|
||||
cookieJar(EhCookieStore)
|
||||
dns(EhDns)
|
||||
proxySelector(ehProxySelector)
|
||||
proxySelector(EhProxySelector)
|
||||
if (Settings.dF) {
|
||||
install(EhSSLSocketFactory)
|
||||
proxy(Proxy.NO_PROXY)
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.net.ProxySelector
|
||||
import java.net.SocketAddress
|
||||
import java.net.URI
|
||||
|
||||
class EhProxySelector internal constructor() : ProxySelector() {
|
||||
object EhProxySelector : ProxySelector() {
|
||||
private var delegation: ProxySelector? = null
|
||||
private var alternative: ProxySelector?
|
||||
|
||||
@@ -83,10 +83,8 @@ class EhProxySelector internal constructor() : ProxySelector() {
|
||||
override fun connectFailed(uri: URI, sa: SocketAddress, ioe: IOException) {}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_DIRECT = 0
|
||||
const val TYPE_SYSTEM = 1
|
||||
const val TYPE_HTTP = 2
|
||||
const val TYPE_SOCKS = 3
|
||||
}
|
||||
const val TYPE_DIRECT = 0
|
||||
const val TYPE_SYSTEM = 1
|
||||
const val TYPE_HTTP = 2
|
||||
const val TYPE_SOCKS = 3
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import android.widget.AutoCompleteTextView
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.hippo.ehviewer.EhApplication
|
||||
import com.hippo.ehviewer.EhProxySelector
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
@@ -165,7 +164,7 @@ class ProxyPreference @JvmOverloads constructor(
|
||||
Settings.proxyIp = ip
|
||||
Settings.proxyPort = port
|
||||
updateSummary(type, ip, port)
|
||||
EhApplication.ehProxySelector.updateProxy()
|
||||
EhProxySelector.updateProxy()
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user