From 2f93995b63dcf8c8e78d98d5c86fcaff44daf19d Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 2 Aug 2021 12:33:19 +0800 Subject: [PATCH] note the test code --- .../com/mogo/launcher/MogoApplication.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 1dd334501b..6b89252b99 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -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(