Files
MoGoEagleEye/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java
2021-01-06 16:59:49 +08:00

308 lines
7.5 KiB
Java

package com.mogo.map;
import android.graphics.Point;
import android.graphics.Rect;
import android.location.Location;
import android.view.View;
import android.view.animation.Interpolator;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.uicontroller.CarCursorOption;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapCameraPosition;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.utils.logger.Logger;
import java.util.List;
/**
* @author congtaowang
* @since 2019-12-26
* <p>
* 描述
*/
public class MogoMapUIController implements IMogoMapUIController {
private static final String TAG = "MogoMapUIController";
private IMogoMapUIController mDelegate;
private static volatile MogoMapUIController sInstance;
private MogoMapUIController() {
initDelegate();
}
public static MogoMapUIController getInstance() {
if ( sInstance == null ) {
synchronized ( MogoMapUIController.class ) {
if ( sInstance == null ) {
sInstance = new MogoMapUIController();
}
}
}
return sInstance;
}
public void setDelegate( IMogoMapUIController mDelegate ) {
this.mDelegate = mDelegate;
}
public static synchronized void release() {
sInstance = null;
}
@Override
public void setTrafficEnabled( boolean visible ) {
if ( mDelegate != null ) {
mDelegate.setTrafficEnabled( visible );
}
}
@Override
public MapControlResult changeZoom( boolean zoom ) {
if ( mDelegate != null ) {
return mDelegate.changeZoom( zoom );
}
return MapControlResult.ERROR;
}
@Override
public MapControlResult changeZoom( float zoom ) {
if ( mDelegate != null ) {
return mDelegate.changeZoom( zoom );
}
return MapControlResult.ERROR;
}
@Override
public void changeMapMode( EnumMapUI mode ) {
if ( mDelegate != null ) {
Logger.d( "whatthefuck-MogoMapUIController", "%s", this );
Logger.d( TAG, "set type: %s", mode.name() );
mDelegate.changeMapMode( mode );
}
}
@Override
public void moveToCenter( MogoLatLng latLng, boolean animate ) {
if ( mDelegate != null ) {
mDelegate.moveToCenter( latLng, animate );
}
}
@Override
public void showMyLocation( boolean visible ) {
if ( mDelegate != null ) {
mDelegate.showMyLocation( visible );
}
}
@Override
public void emphasizeMyLocation() {
if ( mDelegate != null ) {
mDelegate.emphasizeMyLocation();
}
}
@Override
public void showMyLocation( View view ) {
if ( mDelegate != null ) {
mDelegate.showMyLocation( view );
}
}
@Override
public void recoverLockMode() {
if ( mDelegate != null ) {
mDelegate.recoverLockMode();
}
}
@Override
public void loseLockMode() {
if ( mDelegate != null ) {
mDelegate.loseLockMode();
}
}
@Override
public void setLockZoom( int var1 ) {
if ( mDelegate != null ) {
mDelegate.setLockZoom( var1 );
}
}
@Override
public void displayOverview( Rect bounds ) {
if ( mDelegate != null ) {
mDelegate.displayOverview( bounds );
}
}
@Override
public float getScalePerPixel() {
if ( mDelegate != null ) {
return mDelegate.getScalePerPixel();
}
return 0;
}
@Override
public float getZoomLevel() {
if ( mDelegate != null ) {
return mDelegate.getZoomLevel();
}
return 0;
}
@Override
public MogoLatLng getCameraNorthEastPosition() {
if ( mDelegate != null ) {
return mDelegate.getCameraNorthEastPosition();
}
return null;
}
@Override
public MogoLatLng getCameraSouthWestPosition() {
if ( mDelegate != null ) {
return mDelegate.getCameraSouthWestPosition();
}
return null;
}
@Override
public MogoLatLng getWindowCenterLocation() {
if ( mDelegate != null ) {
return mDelegate.getWindowCenterLocation();
}
return null;
}
@Override
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
if ( mDelegate != null ) {
mDelegate.setPointToCenter( mapCenterX, mapCenterY );
}
}
@Override
public Point getLocationPointInScreen( MogoLatLng latLng ) {
if ( mDelegate != null ) {
return mDelegate.getLocationPointInScreen( latLng );
}
return null;
}
@Override
public MogoLatLng getLocationMogoLatLngInScreen( Point point ) {
if ( mDelegate != null ) {
return mDelegate.getLocationMogoLatLngInScreen( point );
}
return null;
}
@Override
public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, long duration ) {
if ( mDelegate != null ) {
mDelegate.startJumpAnimation( marker, high, interpolator, duration );
}
}
@Override
public void setRenderFps( int fps ) {
if ( mDelegate != null ) {
mDelegate.setRenderFps( fps );
}
}
@Override
public void showBounds( String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) {
if ( mDelegate != null ) {
mDelegate.showBounds( tag, carPosition, lonLats, bound, lockCarPosition );
}
}
@Override
public void forceRender() {
if ( mDelegate != null ) {
mDelegate.forceRender();
}
}
@Override
public float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception {
if ( mDelegate != null ) {
return mDelegate.calculateLineDistance( p1, p2 );
}
return 0;
}
@Override
public EnumMapUI getCurrentUiMode() {
if ( mDelegate != null ) {
return mDelegate.getCurrentUiMode();
}
return null;
}
@Override
public void changeMyLocation( Location location ) {
if ( mDelegate != null ) {
mDelegate.changeMyLocation( location );
}
}
@Override
public boolean isCarLocked() {
if ( mDelegate != null ) {
return mDelegate.isCarLocked();
}
return false;
}
@Override
public void setCarCursorOption( CarCursorOption option ) {
if ( mDelegate != null ) {
mDelegate.setCarCursorOption( option );
}
}
@Override
public MapCameraPosition getMapCameraPosition() {
if ( mDelegate != null ) {
return mDelegate.getMapCameraPosition();
}
return null;
}
@Override
public void changeBearing( float bearing ) {
if ( mDelegate != null ) {
mDelegate.changeBearing( bearing );
}
}
@Override
public void rtkEnable( boolean enable ) {
if ( mDelegate != null ) {
mDelegate.rtkEnable( enable );
}
}
@Override
public void destroy() {
mDelegate = null;
release();
}
private void initDelegate() {
if ( mDelegate == null ) {
mDelegate = MogoMapDelegateFactory.getMapUIControllerDelegate();
}
}
}