fix bug of null

This commit is contained in:
zhongchao
2022-02-25 15:42:29 +08:00
parent 3598d7a7f5
commit 858668ae11
2 changed files with 10 additions and 7 deletions

View File

@@ -3,7 +3,6 @@ package com.mogo.cloud.httpdns
import android.os.Handler
import android.os.HandlerThread
import android.os.Message
import android.text.TextUtils
import android.util.ArrayMap
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation
import com.mogo.cloud.httpdns.listener.IMogoHttpDns
@@ -71,10 +70,14 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
if (addressChangedListener == null) {
L.d(TAG, "addressChangeList is null")
}
if (nAddress == null || nAddress.isEmpty()) {
L.e(TAG, "getHttpDnsAddressFromNet nAddress result is null or empty ")
return
}
if (addressMap == null) {
addressMap = nAddress
addressChangedListener?.onAddressChanged(addressMap)
} else if (nAddress != null) {
} else {
addressMap = nAddress
addressChangedListener?.onAddressChanged(mapDiff(nAddress, addressMap!!))
}
@@ -126,9 +129,11 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
L.d(TAG, "getHttpDnsCachedAddress: $type-$host")
httpDnsCache?.let {
val currentLoc = builder.getCurrentLocation()?.getCurrentLocation()
if (currentLoc != null && !TextUtils.equals(it.cityCode, currentLoc.cityCode)) {
getHttpDnsAddress(type, _host)
httpDnsCache = currentLoc
currentLoc?.let { cur ->
if (it.cityCode.isNotEmpty() && cur.cityCode.isNotEmpty()) {
getHttpDnsAddress(type, _host)
httpDnsCache = currentLoc
}
}
}
return addressMap?.get("$type-$host") ?: defaultUrl

View File

@@ -12,12 +12,10 @@ object L {
fun d(tag: String, msg: String) {
if (isDebug) {
Log.d(tag, msg)
// println(msg)
}
}
fun e(tag: String, msg: String) {
Log.e(tag, msg)
// println(msg)
}
}