切换地图的逻辑修改

This commit is contained in:
wangcongtao
2020-10-25 11:08:46 +08:00
parent aafd2cd5db
commit 771e5eed13
44 changed files with 740 additions and 231 deletions

View File

@@ -6,7 +6,7 @@ package com.mogo.map.location;
* <p>
* 定位接口
*/
public interface IMogoLocationClient {
public interface IMogoLocationClient extends IMogoLocationListenerRegister {
/**
* 开始定位
@@ -25,20 +25,6 @@ public interface IMogoLocationClient {
*/
void stop();
/**
* 注册定位回调
*
* @param listener
*/
void addLocationListener( IMogoLocationListener listener );
/**
* 注销定位回调
*
* @param listener
*/
void removeLocationListener( IMogoLocationListener listener );
/**
* 返回上一次有效定位
*

View File

@@ -0,0 +1,24 @@
package com.mogo.map.location;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 地图监听注册管理
*/
public interface IMogoLocationListenerRegister {
/**
* 注册定位回调
*
* @param listener
*/
void addLocationListener( IMogoLocationListener listener );
/**
* 注销定位回调
*
* @param listener
*/
void removeLocationListener( IMogoLocationListener listener );
}

View File

@@ -0,0 +1,75 @@
package com.mogo.map.location;
import java.sql.ClientInfoStatus;
import java.util.HashSet;
import java.util.Set;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 地图监听注册管理
*/
public class MogoLocationListenerRegister implements IMogoLocationListenerRegister {
private static volatile MogoLocationListenerRegister sInstance;
private MogoLocationListenerRegister() {
}
public static MogoLocationListenerRegister getInstance() {
if ( sInstance == null ) {
synchronized ( MogoLocationListenerRegister.class ) {
if ( sInstance == null ) {
sInstance = new MogoLocationListenerRegister();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
/**
* 注册定位回调
*
* @param listener
*/
@Override
public void addLocationListener( IMogoLocationListener listener ) {
if ( listener == null ) {
return;
}
synchronized ( sListeners ) {
sListeners.add( listener );
}
}
/**
* 注销定位回调
*
* @param listener
*/
@Override
public void removeLocationListener( IMogoLocationListener listener ) {
if ( listener == null ) {
return;
}
synchronized ( sListeners ) {
sListeners.remove( listener );
}
}
public Set< IMogoLocationListener > getListeners() {
return sListeners;
}
}