version:1.7
fix: update:增加抢购,修复bug
This commit is contained in:
@@ -2,6 +2,7 @@ package com.uiuios.aios.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -9,6 +10,7 @@ import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.baidu.location.LocationClientOption;
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -27,7 +29,6 @@ public class AmapManager {
|
||||
private LocationClientOption mOption;
|
||||
private BDLocation mLocation;
|
||||
private CacheHelper mCacheHelper;
|
||||
private MMKV mmkv = MMKV.defaultMMKV();
|
||||
|
||||
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "map_longitude_key";
|
||||
@@ -38,6 +39,7 @@ public class AmapManager {
|
||||
private AmapManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
initAmap();
|
||||
}
|
||||
|
||||
@@ -58,7 +60,10 @@ public class AmapManager {
|
||||
}
|
||||
|
||||
public void initAmap() {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
if (mLocationClient == null) {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
}
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
mLocationClient.setLocOption(getDefaultLocationClientOption());
|
||||
mLocationClient.registerLocationListener(mListener);
|
||||
mLocationClient.stop();
|
||||
@@ -75,7 +80,7 @@ public class AmapManager {
|
||||
|
||||
public BDLocation getNowMapLocation() {
|
||||
if (mLocation == null) {
|
||||
String aMapLocationjson = mmkv.decodeString(AMAPLOCATION_JSON_KEY);
|
||||
String aMapLocationjson = SPUtils.getInstance().getString(AMAPLOCATION_JSON_KEY,"");
|
||||
if (TextUtils.isEmpty(aMapLocationjson)) {
|
||||
return null;
|
||||
}
|
||||
@@ -148,7 +153,7 @@ public class AmapManager {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
mmkv.encode(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
SPUtils.getInstance().put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
|
||||
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
|
||||
@@ -282,6 +287,9 @@ public class AmapManager {
|
||||
// }
|
||||
Log.e(TAG, "AmapAddress: " + mCacheHelper.getAsString(ADDRESS_KEY));
|
||||
Log.e(TAG, "AmapError: " + mCacheHelper.getAsString(ERROR_KEY));
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-network");
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-gps");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user