diff --git a/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/HttpDnsHelper.kt b/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/HttpDnsHelper.kt index b8c0cb2..bab84cb 100644 --- a/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/HttpDnsHelper.kt +++ b/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/HttpDnsHelper.kt @@ -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 diff --git a/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/util/L.kt b/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/util/L.kt index d908640..4b9698a 100644 --- a/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/util/L.kt +++ b/foudations/mogo-httpdns/src/main/java/com/mogo/cloud/httpdns/util/L.kt @@ -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) } } \ No newline at end of file