note the test code
This commit is contained in:
@@ -180,49 +180,49 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
clientConfig.setLoopCheckDelay(5 * 1000);
|
||||
|
||||
// 设置DNS经纬度位置
|
||||
clientConfig.setIHttpDnsCurrentLocation(() -> {
|
||||
SocketTestBroadCastReceiver.SocketTestData socketTestData = SocketTestBroadCastReceiver.SocketTestData.getInstance();
|
||||
Log.d("TEST-SOCKET","socketTestData cityCode: " + socketTestData.getCityCode());
|
||||
return new HttpDnsSimpleLocation(socketTestData.getCityCode(),socketTestData.getLat(),socketTestData.getLon()); //todo 对象唯一实例优化
|
||||
});
|
||||
// clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
// @Override
|
||||
// public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
// MogoLocation mogoLocation =
|
||||
// MogoApisHandler.getInstance()
|
||||
// .getApis().getMapServiceApi()
|
||||
// .getSingletonLocationClient(getApp())
|
||||
// .getLastKnowLocation();
|
||||
// HttpDnsSimpleLocation httpDnsSimpleLocation;
|
||||
// if (mogoLocation != null
|
||||
// && mogoLocation.getLatitude() != 0
|
||||
// && mogoLocation.getLongitude() != 0) {
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
// mogoLocation.getCityCode(),
|
||||
// mogoLocation.getLatitude(),
|
||||
// mogoLocation.getLongitude());
|
||||
// Logger.i(TAG, "使用实时GPS信息:" + httpDnsSimpleLocation);
|
||||
// } else {
|
||||
// String ciyCode = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_CITY_CODE);
|
||||
// String latitude = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_LATITUDE);
|
||||
// String longitude = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_LONGITUDE);
|
||||
// try {
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
// ciyCode,
|
||||
// Double.parseDouble(latitude),
|
||||
// Double.parseDouble(longitude));
|
||||
// } catch (NumberFormatException e) {
|
||||
// e.printStackTrace();
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
|
||||
// }
|
||||
// Logger.i(TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
// }
|
||||
// return httpDnsSimpleLocation;
|
||||
// }
|
||||
// clientConfig.setIHttpDnsCurrentLocation(() -> {
|
||||
// SocketTestBroadCastReceiver.SocketTestData socketTestData = SocketTestBroadCastReceiver.SocketTestData.getInstance();
|
||||
// Log.d("TEST-SOCKET","socketTestData cityCode: " + socketTestData.getCityCode());
|
||||
// return new HttpDnsSimpleLocation(socketTestData.getCityCode(),socketTestData.getLat(),socketTestData.getLon()); //todo 对象唯一实例优化
|
||||
// });
|
||||
clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
@Override
|
||||
public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
MogoLocation mogoLocation =
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis().getMapServiceApi()
|
||||
.getSingletonLocationClient(getApp())
|
||||
.getLastKnowLocation();
|
||||
HttpDnsSimpleLocation httpDnsSimpleLocation;
|
||||
if (mogoLocation != null
|
||||
&& mogoLocation.getLatitude() != 0
|
||||
&& mogoLocation.getLongitude() != 0) {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
mogoLocation.getCityCode(),
|
||||
mogoLocation.getLatitude(),
|
||||
mogoLocation.getLongitude());
|
||||
Logger.i(TAG, "使用实时GPS信息:" + httpDnsSimpleLocation);
|
||||
} else {
|
||||
String ciyCode = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_CITY_CODE);
|
||||
String latitude = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_LATITUDE);
|
||||
String longitude = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_LONGITUDE);
|
||||
try {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
ciyCode,
|
||||
Double.parseDouble(latitude),
|
||||
Double.parseDouble(longitude));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
|
||||
}
|
||||
Logger.i(TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
}
|
||||
return httpDnsSimpleLocation;
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化SDK,可以设置状态回调来监听
|
||||
MoGoAiCloudClient.getInstance().init(this, clientConfig).addTokenCallbacks(
|
||||
|
||||
Reference in New Issue
Block a user