切换地图的逻辑修改
This commit is contained in:
@@ -3,9 +3,15 @@ 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.map.impl.amap.AMapBaseMapView;
|
||||
import com.mogo.map.impl.amap.uicontroller.AMapUIController;
|
||||
import com.mogo.map.impl.custom.CustomMapView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
@@ -30,15 +36,63 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
private boolean mIsFirstDisplayVRMode = true;
|
||||
|
||||
@Override
|
||||
public IMogoMap getMap() {
|
||||
return super.getMap();
|
||||
protected void addDleMaps() {
|
||||
mAMapView = new AMapBaseMapView().create( getContext() );
|
||||
mCustomMapView = new CustomMapView().create( getContext() );
|
||||
|
||||
if ( mAMapView != null ) {
|
||||
final View mapView = mAMapView.getMapView();
|
||||
if ( mapView != null ) {
|
||||
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
|
||||
} else {
|
||||
Logger.e( TAG, "create MapView instance failed." );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
}
|
||||
|
||||
// if ( mCustomMapView != null ) {
|
||||
// final View mapView = mCustomMapView.getMapView();
|
||||
// if ( mapView != null ) {
|
||||
// addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
|
||||
// } else {
|
||||
// Logger.e( TAG, "create MapView instance failed." );
|
||||
// }
|
||||
// } else {
|
||||
// Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
// }
|
||||
|
||||
mMapView = mAMapView;
|
||||
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMogoMapView createMapView( Context context ) {
|
||||
MogoMapDelegateFactory.createMapView( context );
|
||||
return MogoMapDelegateFactory.getMapView();
|
||||
public void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
MogoMap.getInstance().init( getContext(), mAMapView.getMap() );
|
||||
MogoMapUIController.getInstance().setDelegate( AMapUIController.getInstance() );
|
||||
MogoMarkerManager.getInstance( getContext() ).removeMarkers();
|
||||
mCustomMapView.onPause();
|
||||
mCustomMapView.getMapView().setVisibility( View.GONE );
|
||||
mAMapView.onResume();
|
||||
mAMapView.getMapView().setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
if ( mIsFirstDisplayVRMode ) {
|
||||
mCustomMapView.onCreate( null );
|
||||
mIsFirstDisplayVRMode = false;
|
||||
}
|
||||
MogoMap.getInstance().init( getContext(), mCustomMapView.getMap() );
|
||||
MogoMapUIController.getInstance().setDelegate( com.mogo.map.impl.custom.uicontroller.AMapUIController.getInstance() );
|
||||
MogoMarkerManager.getInstance( getContext() ).removeMarkers();
|
||||
mCustomMapView.onResume();
|
||||
mCustomMapView.getMapView().setVisibility( View.VISIBLE );
|
||||
mAMapView.onPause();
|
||||
mAMapView.getMapView().setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,14 +111,12 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
Logger.d( TAG, "onPause" );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Logger.d( TAG, "onDestroy" );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,9 +128,4 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapView getMapView() {
|
||||
return super.getMapView();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user