Commit 88db9469 by 罗翻

更改locationUtils

parent aa59c105
package com.dayu.location.base; package com.dayu.location.base;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -20,12 +21,11 @@ import java.io.File; ...@@ -20,12 +21,11 @@ import java.io.File;
*/ */
public class LocationUtils { public class LocationUtils {
@SuppressLint("StaticFieldLeak")
private static AMapLocationClient mlocationClient; private static AMapLocationClient mlocationClient;
private static AMapLocation sLocation = null; private static AMapLocation sLocation = null;
private static boolean flag = true; private static boolean flag = true;
private static MyLocationListener mListener;
private static Handler mHandler; private static Handler mHandler;
private static OpenMarketListener marketListener;
/** /**
* @param context * @param context
...@@ -75,8 +75,7 @@ public class LocationUtils { ...@@ -75,8 +75,7 @@ public class LocationUtils {
* @Title: getCurrentLocation * @Title: getCurrentLocation
* @Description: 获取位置,重新发起获取位置请求 * @Description: 获取位置,重新发起获取位置请求
*/ */
public static void getCurrentLocation(MyLocationListener listener) { public static void getCurrentLocation(final MyLocationListener listener) {
mListener = listener;
if (mlocationClient == null) { if (mlocationClient == null) {
return; return;
} }
...@@ -87,7 +86,7 @@ public class LocationUtils { ...@@ -87,7 +86,7 @@ public class LocationUtils {
@Override @Override
public void run() { public void run() {
if (flag) { if (flag) {
mListener.result(sLocation); listener.result(sLocation);
flag = false; flag = false;
mlocationClient.stopLocation(); mlocationClient.stopLocation();
} }
...@@ -102,7 +101,7 @@ public class LocationUtils { ...@@ -102,7 +101,7 @@ public class LocationUtils {
flag = false; flag = false;
mlocationClient.stopLocation(); mlocationClient.stopLocation();
sLocation = location; sLocation = location;
mListener.result(location); listener.result(location);
mHandler = null; mHandler = null;
} }
} }
...@@ -120,7 +119,6 @@ public class LocationUtils { ...@@ -120,7 +119,6 @@ public class LocationUtils {
if (mlocationClient != null) { if (mlocationClient != null) {
mlocationClient.onDestroy(); mlocationClient.onDestroy();
} }
mListener = null;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment