地图依赖重构
This commit is contained in:
@@ -9,9 +9,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -39,15 +36,10 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
private boolean mIsVrMode = false;
|
||||
|
||||
@Override
|
||||
protected void addDleMaps() {
|
||||
|
||||
display2DMap( true, true );
|
||||
}
|
||||
|
||||
private void addAMapView(){
|
||||
mAMapView = new AMapBaseMapView().create( getContext() );
|
||||
if ( mAMapView != null ) {
|
||||
final View mapView = mAMapView.getMapView();
|
||||
protected void addMapView( Context context ) {
|
||||
mMapView = MogoMapDelegateFactory.getMapView( 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 ) );
|
||||
} else {
|
||||
@@ -58,73 +50,6 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
}
|
||||
}
|
||||
|
||||
private void addVrMapView(){
|
||||
mCustomMapView = new CustomMapView().create( getContext() );
|
||||
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." );
|
||||
}
|
||||
mCustomMapView.onCreate( null );
|
||||
}
|
||||
|
||||
private void removeVrMapView(){
|
||||
try {
|
||||
mCustomMapView.onDestroy();
|
||||
removeView( mCustomMapView.getMapView() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAMapView(){
|
||||
try {
|
||||
mAMapView.onPause();
|
||||
removeView( mAMapView.getMapView() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
mIsVrMode = false;
|
||||
MogoMarkerManager.getInstance( getContext() ).removeMarkers();
|
||||
removeVrMapView();
|
||||
addAMapView();
|
||||
mMapView = mAMapView;
|
||||
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
|
||||
MogoMapUIController.getInstance().setDelegate( AMapUIController.getInstance() );
|
||||
mAMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
mIsVrMode = true;
|
||||
MogoMarkerManager.getInstance( getContext() ).removeMarkers();
|
||||
removeAMapView();
|
||||
addVrMapView();
|
||||
mMapView = mCustomMapView;
|
||||
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
|
||||
MogoMapUIController.getInstance().setDelegate( com.mogo.map.impl.custom.uicontroller.AMapUIController.getInstance() );
|
||||
mCustomMapView.onResume();
|
||||
post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
getMap().getUIController().showMyLocation( true );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
return mIsVrMode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user