Skip to content

Commit cec9794

Browse files
sevenhhearchurcode
authored andcommitted
开源版和风天气 api 和 key 适配
Change-Id: If0e9f95459487ffcca4ed266ae9d5b2ba8c139ed
1 parent 7f757a8 commit cec9794

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

app-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"XgUSAAccessId": "1530001537",
88
"XgUSAAccessKey": "A1S4XT4V7XSM",
99
"TencentMapSDKValue": "ZV6BZ-3ATCP-5BZDE-VFIJI-I7NO6-TIBAG",
10-
"HEweatherKey": ""
10+
"HEweatherKey": "e8e05ddc05ea47a6a25c68f34d850eb1"
1111
}

app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/HomeFragment.kt

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class HomeFragment : BaseFragment(), HomeFragmentView, MyCallback {
8383
initView()
8484
setListener()
8585
registBrodcast()
86+
showWeather(false)
8687
}
8788

8889
override fun onResume() {

app/src/main/java/com/tencent/iot/explorer/link/kitlink/util/WeatherUtils.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import android.content.Context
44
import android.util.Log
55
import com.alibaba.fastjson.JSON
66
import com.tencent.iot.explorer.link.BuildConfig
7+
import com.tencent.iot.explorer.link.T
78
import com.tencent.iot.explorer.link.kitlink.entity.WeatherInfo
89
import com.tencent.iot.explorer.link.core.utils.LocationUtil
10+
import com.tencent.iot.explorer.link.kitlink.consts.CommonField
911
import com.tencent.iot.explorer.link.kitlink.entity.CityInfo
1012
import com.tencent.map.geolocation.TencentLocation
1113
import com.tencent.map.geolocation.TencentLocationListener
@@ -19,7 +21,11 @@ object WeatherUtils {
1921
var defaultLang = "zh"
2022

2123
fun getWeatherInfo(cityInfo: CityInfo, listener: OnWeatherListener) {
22-
var url = "https://api.heweather.net/v7/weather/now?location=${cityInfo.lon},${cityInfo.lat}&key=$key&lang=$defaultLang"
24+
var openSourcePrefix = ""
25+
if (!T.getContext().applicationInfo.packageName.equals(CommonField.PUBLISH_TAG)) {
26+
openSourcePrefix = "dev"
27+
}
28+
var url = "https://${openSourcePrefix}api.heweather.net/v7/weather/now?location=${cityInfo.lon},${cityInfo.lat}&key=$key&lang=$defaultLang"
2329
val request = Request.Builder().url(url).get().build() //添加头部信息
2430
okHttpClient.newCall(request).enqueue(object : Callback{
2531
override fun onFailure(call: Call, e: IOException) {

0 commit comments

Comments
 (0)