86 lines
2.0 KiB
Java
86 lines
2.0 KiB
Java
package com.mogo.map;
|
|
|
|
import android.content.Context;
|
|
|
|
import com.mogo.map.impl.amap.location.ALocationClient;
|
|
import com.mogo.map.location.IMogoLocationClient;
|
|
import com.mogo.map.location.IMogoLocationListener;
|
|
import com.mogo.map.location.MogoLocation;
|
|
|
|
/**
|
|
* @author congtaowang
|
|
* @since 2019-12-19
|
|
* <p>
|
|
*/
|
|
public class MogoLocationClient implements IMogoLocationClient {
|
|
|
|
private static volatile MogoLocationClient sInstance;
|
|
|
|
public MogoLocationClient( Context context ) {
|
|
mDelegate = new ALocationClient( context );
|
|
}
|
|
|
|
public static MogoLocationClient getInstance( Context context ) {
|
|
if ( sInstance == null ) {
|
|
synchronized ( MogoLocationClient.class ) {
|
|
if ( sInstance == null ) {
|
|
sInstance = new MogoLocationClient( context );
|
|
}
|
|
}
|
|
}
|
|
return sInstance;
|
|
}
|
|
|
|
private IMogoLocationClient mDelegate;
|
|
|
|
@Override
|
|
public void start() {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.start();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void start( long interval ) {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.start( interval );
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void stop() {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.stop();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void addLocationListener( IMogoLocationListener listener ) {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.addLocationListener( listener );
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void removeLocationListener( IMogoLocationListener listener ) {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.removeLocationListener( listener );
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public MogoLocation getLastKnowLocation() {
|
|
if ( mDelegate != null ) {
|
|
return mDelegate.getLastKnowLocation();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void destroy() {
|
|
if ( mDelegate != null ) {
|
|
mDelegate.destroy();
|
|
}
|
|
}
|
|
}
|