[base_3.4.0-map-sdk]
This commit is contained in:
@@ -22,7 +22,7 @@ import com.zhjt.service.chain.ChainLog
|
||||
* 封装高德地图通过设备GPS获取到的位置信息,频率1s一次,坐标系为CJC20
|
||||
* 这里的数据仅用于非高精度业务
|
||||
*/
|
||||
class GDLocationClient private constructor(context: Context) : AMapLocationListener,
|
||||
class GDLocationClient private constructor() : AMapLocationListener,
|
||||
IMogoGDLocationClient {
|
||||
//声明LocationClient对象
|
||||
private lateinit var mLocationClient: AMapLocationClient
|
||||
@@ -40,7 +40,7 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
Handler(thread.looper)
|
||||
}
|
||||
|
||||
init {
|
||||
override fun start(context: Context) {
|
||||
AMapLocationClient.updatePrivacyShow(context, true, true)
|
||||
AMapLocationClient.updatePrivacyAgree(context, true)
|
||||
try {
|
||||
@@ -60,9 +60,6 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
if (mLocationClient != null) {
|
||||
mLocationClient.startLocation()
|
||||
}
|
||||
@@ -169,20 +166,8 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var gdLocationClient: GDLocationClient? = null
|
||||
private val obj = ByteArray(0)
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(context: Context): GDLocationClient? {
|
||||
if (gdLocationClient == null) {
|
||||
synchronized(obj) {
|
||||
if (gdLocationClient == null) {
|
||||
gdLocationClient = GDLocationClient(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return gdLocationClient
|
||||
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
GDLocationClient()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user