fix bug of null
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user