[dev_arch_opt_3.0]

[Change]
[
1、删除旧版地图本定位注册
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-01-28 19:44:46 +08:00
parent 68a00f1239
commit 9a5def9afa
14 changed files with 0 additions and 594 deletions

View File

@@ -1,157 +0,0 @@
package com.mogo.map.location;
import android.content.Context;
import android.os.Trace;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.utils.ObjectUtils;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.Set;
/**
* @author congtaowang
* @since 2019-12-19
* <p>
* 自研定位
*/
public class ALocationClient implements IMogoLocationClient {
private static final String TAG = "ALocationClient";
private MogoLocation mLastLocation;
private final LocationListener mListener = new InternalLocationListener();
private boolean mIsDestroyed = false;
public ALocationClient( Context context ) {
mClient = new LocationClient( context );
mClient.registerListener( mListener );
mLastLocation = ObjectUtils.fromLocation( mClient.getLastKnownMogoLocation() );
if ( mLastLocation == null ) {
mLastLocation = new MogoLocation();
}
}
private LocationClient mClient;
@Override
public void start() {
start( 2_000L );
}
@Override
public void start( long interval ) {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( mClient != null ) {
mClient.start();
}
}
@Override
public void stop() {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( mClient != null && mClient.isAGpsStarted() ) {
mClient.stop();
}
}
@Override
public void addLocationListener( IMogoLocationListener listener ) {
// do not impl.
}
@Override
public void removeLocationListener( IMogoLocationListener listener ) {
// do not impl.
}
@Override
public MogoLocation getLastKnowLocation() {
if ( mIsDestroyed ) {
destroyWarming();
return null;
}
return mLastLocation;
}
@Override
public synchronized void destroy() {
mIsDestroyed = true;
if ( mClient != null ) {
mClient.unRegisterListener( mListener );
mClient.destory();
}
mClient = null;
mLastLocation = null;
}
private class InternalLocationListener implements LocationListener {
@Override
public void onLocationChanged( @NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location ) {
if ( mIsDestroyed ) {
destroyWarming();
return;
}
if ( location == null ||
location.getLat() == 0.0D ||
location.getLon() == 0.0D ) {
return;
}
Trace.beginSection( "timer.onLocationChanged" );
mLastLocation = ObjectUtils.fromLocation( location );
UiThreadHandler.post(() -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation, 0, false));
Set< IMogoLocationListener > listeners = MogoLocationListenerRegister.getInstance().getListeners();
synchronized ( listeners ) {
Iterator< IMogoLocationListener > listenerIterator = listeners.iterator();
while ( listenerIterator.hasNext() ) {
listenerIterator.next().onLocationChanged( mLastLocation.clone() );
}
}
Trace.endSection();
}
}
private void destroyWarming() {
CallerLogger.INSTANCE.w( TAG, "location client has destroyed." );
}
@Override
public void updateLocation(Object locationToUpdate) {
if (locationToUpdate == null) {
return;
}
if (locationToUpdate instanceof MogoLocation) {
return;
}
// if (locationToUpdate instanceof RTKAutopilotLocationBean) {
// RTKAutopilotLocationBean current = (RTKAutopilotLocationBean) locationToUpdate;
// if (mClient != null) {
// mClient.updateRTKAutoPilotLocation(current);
// }
// }
if (locationToUpdate instanceof com.zhidaoauto.map.sdk.open.query.LonLatPoint) {
LonLatPoint current = (LonLatPoint) locationToUpdate;
if (mClient != null) {
mClient.updateLocation(current);
}
}
}
}