切换地图的逻辑修改
This commit is contained in:
@@ -3,14 +3,10 @@ package com.mogo.map;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -22,7 +18,10 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
|
||||
|
||||
private static final String TAG = "MogoBaseMapView";
|
||||
|
||||
private IMogoMapView mMapView;
|
||||
protected IMogoMapView mMapView;
|
||||
|
||||
protected IMogoMapView mAMapView;
|
||||
protected IMogoMapView mCustomMapView;
|
||||
|
||||
public MogoBaseMapView( Context context ) {
|
||||
this( context, null );
|
||||
@@ -38,27 +37,14 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
|
||||
}
|
||||
|
||||
private void init( Context context ) {
|
||||
mMapView = createMapView( context );
|
||||
if ( mMapView != null ) {
|
||||
final View mapView = mMapView.getMapView();
|
||||
if ( mapView != null ) {
|
||||
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
|
||||
MogoMap.getInstance().init( context, getMap() );
|
||||
} else {
|
||||
Logger.e( TAG, "create MapView instance failed." );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
}
|
||||
addDleMaps();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建地图实例
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected abstract IMogoMapView createMapView( Context context );
|
||||
protected abstract void addDleMaps();
|
||||
|
||||
public abstract void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto );
|
||||
|
||||
public abstract void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto );
|
||||
|
||||
@Override
|
||||
public void onCreate( Bundle bundle ) {
|
||||
@@ -109,8 +95,4 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IMogoMapView getMapView() {
|
||||
return mMapView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
/**
|
||||
* 返回上一次有效定位
|
||||
*
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/23
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoCarLocationChangedListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册车辆位置变化监听,非业务使用
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener );
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* <p>
|
||||
* 导航操作
|
||||
*/
|
||||
public interface IMogoNavi {
|
||||
public interface IMogoNavi extends IMogoCarLocationChangedListenerRegister, IMogoOperationListenerRegister{
|
||||
|
||||
/**
|
||||
* 开启路径规划并导航
|
||||
@@ -97,12 +97,6 @@ public interface IMogoNavi {
|
||||
*/
|
||||
OnCalculatePathItemClickInteraction getItemClickInteraction();
|
||||
|
||||
|
||||
/**
|
||||
* 设置线条点击回调
|
||||
*/
|
||||
void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction );
|
||||
|
||||
/**
|
||||
* 清除规划的路线
|
||||
*/
|
||||
@@ -151,13 +145,6 @@ public interface IMogoNavi {
|
||||
*/
|
||||
Location getCarLocation2();
|
||||
|
||||
/**
|
||||
* 注册车辆位置变化监听,非业务使用
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener );
|
||||
|
||||
/**
|
||||
* 打开巡航模式
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/23
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoOperationListenerRegister {
|
||||
|
||||
/**
|
||||
* 设置线条点击回调
|
||||
*/
|
||||
void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/23
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MogoCarLocationChangedListenerRegister implements IMogoCarLocationChangedListenerRegister {
|
||||
|
||||
private static volatile MogoCarLocationChangedListenerRegister sInstance;
|
||||
private IMogoCarLocationChangedListener2 listener;
|
||||
|
||||
private MogoCarLocationChangedListenerRegister(){}
|
||||
|
||||
public static MogoCarLocationChangedListenerRegister getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( MogoCarLocationChangedListenerRegister.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new MogoCarLocationChangedListenerRegister();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册车辆位置变化监听,非业务使用
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
@Override
|
||||
public void registerCarLocationChangedListener( IMogoCarLocationChangedListener2 listener ) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public IMogoCarLocationChangedListener2 getListener() {
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.map.navi;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/23
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MogoOperationListenerRegister implements IMogoOperationListenerRegister {
|
||||
|
||||
private static volatile MogoOperationListenerRegister sInstance;
|
||||
private OnCalculatePathItemClickInteraction itemClickInteraction;
|
||||
|
||||
private MogoOperationListenerRegister(){}
|
||||
|
||||
public static MogoOperationListenerRegister getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( MogoOperationListenerRegister.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new MogoOperationListenerRegister();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线条点击回调
|
||||
*/
|
||||
public void setLineClickInteraction( OnCalculatePathItemClickInteraction itemClickInteraction ) {
|
||||
this.itemClickInteraction = itemClickInteraction;
|
||||
}
|
||||
|
||||
public OnCalculatePathItemClickInteraction getItemClickInteraction() {
|
||||
return itemClickInteraction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user