diff --git a/common/src/main/java/com/yunbao/common/utils/LocationUtil.java b/common/src/main/java/com/yunbao/common/utils/LocationUtil.java index 564d43ba7..0c4e116b7 100644 --- a/common/src/main/java/com/yunbao/common/utils/LocationUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/LocationUtil.java @@ -2,10 +2,10 @@ package com.yunbao.common.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.tencent.map.geolocation.TencentLocation; -import com.tencent.map.geolocation.TencentLocationListener; -import com.tencent.map.geolocation.TencentLocationManager; -import com.tencent.map.geolocation.TencentLocationRequest; +//import com.tencent.map.geolocation.TencentLocation; +//import com.tencent.map.geolocation.TencentLocationListener; +//import com.tencent.map.geolocation.TencentLocationManager; +//import com.tencent.map.geolocation.TencentLocationRequest; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.bean.TxLocationBean; @@ -23,12 +23,12 @@ import java.util.List; public class LocationUtil { private static final String TAG = "定位"; private static LocationUtil sInstance; - private TencentLocationManager mLocationManager; +// private TencentLocationManager mLocationManager; private boolean mLocationStarted; private boolean mNeedPostLocationEvent;//是否需要发送定位成功事件 private LocationUtil() { - mLocationManager = TencentLocationManager.getInstance(CommonAppContext.sInstance); +// mLocationManager = TencentLocationManager.getInstance(CommonAppContext.sInstance); } public static LocationUtil getInstance() { @@ -42,26 +42,26 @@ public class LocationUtil { return sInstance; } - - private TencentLocationListener mLocationListener = new TencentLocationListener() { - @Override - public void onLocationChanged(TencentLocation location, int code, String reason) { - if (code == TencentLocation.ERROR_OK) { - double lng = location.getLongitude();//经度 - double lat = location.getLatitude();//纬度 - L.e(TAG, "获取经纬度成功------>经度:" + lng + ",纬度:" + lat); - CommonHttpUtil.getAddressInfoByTxLocaitonSdk(lng, lat, 0, 1, CommonHttpConsts.GET_LOCAITON, mCallback); - if (mNeedPostLocationEvent) { - EventBus.getDefault().post(new LocationEvent(lng, lat)); - } - } - } - - @Override - public void onStatusUpdate(String s, int i, String s1) { - - } - }; +// +// private TencentLocationListener mLocationListener = new TencentLocationListener() { +// @Override +// public void onLocationChanged(TencentLocation location, int code, String reason) { +// if (code == TencentLocation.ERROR_OK) { +// double lng = location.getLongitude();//经度 +// double lat = location.getLatitude();//纬度 +// L.e(TAG, "获取经纬度成功------>经度:" + lng + ",纬度:" + lat); +// CommonHttpUtil.getAddressInfoByTxLocaitonSdk(lng, lat, 0, 1, CommonHttpConsts.GET_LOCAITON, mCallback); +// if (mNeedPostLocationEvent) { +// EventBus.getDefault().post(new LocationEvent(lng, lat)); +// } +// } +// } +// +// @Override +// public void onStatusUpdate(String s, int i, String s1) { +// +// } +// }; private HttpCallback mCallback = new HttpCallback() { @Override @@ -86,29 +86,29 @@ public class LocationUtil { //启动定位 public void startLocation() { - if (!mLocationStarted && mLocationManager != null) { - mLocationStarted = true; - L.e(TAG, "开启定位"); - TencentLocationRequest request = TencentLocationRequest - .create() - .setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO) - .setInterval(60 * 60 * 1000);//1小时定一次位 - - //当定位周期大于0时, 不论是否有得到新的定位结果, 位置监听器都会按定位周期定时被回调; - // 当定位周期等于0时, 仅当有新的定位结果时, 位置监听器才会被回调(即, 回调时机存在不确定性). - // 如果需要周期性回调, 建议将 定位周期 设置为 5000-10000ms - mLocationManager.requestLocationUpdates(request, mLocationListener); - } +// if (!mLocationStarted && mLocationManager != null) { +// mLocationStarted = true; +// L.e(TAG, "开启定位"); +// TencentLocationRequest request = TencentLocationRequest +// .create() +// .setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO) +// .setInterval(60 * 60 * 1000);//1小时定一次位 +// +// //当定位周期大于0时, 不论是否有得到新的定位结果, 位置监听器都会按定位周期定时被回调; +// // 当定位周期等于0时, 仅当有新的定位结果时, 位置监听器才会被回调(即, 回调时机存在不确定性). +// // 如果需要周期性回调, 建议将 定位周期 设置为 5000-10000ms +// mLocationManager.requestLocationUpdates(request, mLocationListener); +// } } //停止定位 public void stopLocation() { - CommonHttpUtil.cancel(CommonHttpConsts.GET_LOCAITON); - if (mLocationStarted && mLocationManager != null) { - L.e(TAG, "关闭定位"); - mLocationManager.removeUpdates(mLocationListener); - mLocationStarted = false; - } +// CommonHttpUtil.cancel(CommonHttpConsts.GET_LOCAITON); +// if (mLocationStarted && mLocationManager != null) { +// L.e(TAG, "关闭定位"); +// mLocationManager.removeUpdates(mLocationListener); +// mLocationStarted = false; +// } } public void setNeedPostLocationEvent(boolean needPostLocationEvent) {