merge from qa
This commit is contained in:
@@ -2,57 +2,22 @@ package com.mogo.module.service;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.service.refresh.AutoRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -128,6 +93,7 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
MarkerServiceHandler.init( context );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
|
||||
}, 5_000L );
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -63,6 +64,8 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.http.HEAD;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
@@ -190,23 +193,25 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动刷新:锁车、缩放比例:16、半径 2KM
|
||||
*/
|
||||
private void invokeAutoRefresh() {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
return;
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
|
||||
mUiController.changeZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
};
|
||||
|
||||
/**
|
||||
* 自动刷新:锁车、缩放比例:16、半径 2KM
|
||||
*/
|
||||
private void invokeAutoRefresh() {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
notifyRefreshData( mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
return;
|
||||
}
|
||||
};
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
|
||||
mUiController.changeZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
notifyRefreshData( mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
||||
/**
|
||||
@@ -271,12 +276,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
private boolean mIsFirstAccOn = true;
|
||||
|
||||
public void init( Context context ) {
|
||||
mContext = context;
|
||||
|
||||
initWorkThread();
|
||||
|
||||
MarkerServiceHandler.init( mContext );
|
||||
mRefreshModel = new RefreshModel( context );
|
||||
mMogoMapService = MarkerServiceHandler.getMapService();
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
@@ -364,6 +370,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( ro.mLonLat == null ) {
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
mRefreshModel.refreshData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
@@ -617,9 +624,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
// 自动刷新触发
|
||||
final MogoLatLng point = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
if ( mLastAutoRefreshLocation == null ) {
|
||||
mLastAutoRefreshLocation = point;
|
||||
mLoopRequest = true;
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
startFirstLocationRequest( point );
|
||||
return;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance( mLastAutoRefreshLocation, point );
|
||||
@@ -633,8 +638,27 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次定位成功后,执行道路事件的刷新
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
private void startFirstLocationRequest( MogoLatLng point ) {
|
||||
mLastAutoRefreshLocation = point;
|
||||
mLoopRequest = true;
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2( Location latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return;
|
||||
}
|
||||
// poi 定位无法获取时,使用该定位
|
||||
if ( mLastAutoRefreshLocation == null ) {
|
||||
MogoLatLng point = new MogoLatLng( latLng.getLatitude(), latLng.getLongitude() );
|
||||
startFirstLocationRequest( point );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -715,17 +739,19 @@ public class MogoServices implements IMogoMapListener,
|
||||
break;
|
||||
case ACC_STATUS:
|
||||
if ( isTrue ) {
|
||||
mADASController.showADAS();
|
||||
refreshStrategy();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).start();
|
||||
} else {
|
||||
try {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).stop();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
if ( mIsFirstAccOn ) {
|
||||
mIsFirstAccOn = false;
|
||||
return;
|
||||
}
|
||||
refreshStrategy();
|
||||
mADASController.showADAS();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).start();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
refreshStrategy();
|
||||
}, 3_000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).stop();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -774,7 +800,12 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ) {
|
||||
delay = mRefreshRemainingTime;
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay );
|
||||
if ( time == 0 ) {
|
||||
Logger.d( TAG, "立即刷新" );
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay );
|
||||
}
|
||||
Logger.i( TAG, "下次刷新时间:%ss后", mRefreshRemainingTime );
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ package com.mogo.module.service.intent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.receiver.AccStatusReceiver;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
@@ -18,16 +19,21 @@ public
|
||||
*/
|
||||
class AccStatusIntentHandler implements IntentHandler {
|
||||
|
||||
public static final byte ACC_ON = 1;
|
||||
public static final byte ACC_OFF = 0;
|
||||
public static final byte ACC_OFF_DELAY = 3;
|
||||
|
||||
private static final String TAG = "AccStatusIntentHandler";
|
||||
|
||||
private static volatile AccStatusIntentHandler sInstance;
|
||||
|
||||
private AccStatusIntentHandler(){}
|
||||
private AccStatusIntentHandler() {
|
||||
}
|
||||
|
||||
public static AccStatusIntentHandler getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( AccStatusIntentHandler.class ) {
|
||||
if( sInstance == null ){
|
||||
public static AccStatusIntentHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AccStatusIntentHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AccStatusIntentHandler();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +41,7 @@ class AccStatusIntentHandler implements IntentHandler {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@@ -43,15 +49,26 @@ class AccStatusIntentHandler implements IntentHandler {
|
||||
public void handle( Context context, Intent intent ) {
|
||||
String action = intent.getAction();
|
||||
if ( Intent.ACTION_POWER_CONNECTED.equals( action ) ) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, true );
|
||||
Logger.d( TAG, "acc status: %s", true );
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, true );
|
||||
Logger.d( TAG, "acc status: %s", true );
|
||||
}
|
||||
} else if ( Intent.ACTION_POWER_DISCONNECTED.equals( action ) ) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, false );
|
||||
Logger.d( TAG, "acc status: %s", false );
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, false );
|
||||
Logger.d( TAG, "acc status: %s", false );
|
||||
}
|
||||
} else if ( AccStatusReceiver.ACTION_NWD_ACC.equals( action ) ) {
|
||||
int state = intent.getByteExtra( AccStatusReceiver.PARAM_ACC_STATUS, ( byte ) 0 );
|
||||
Logger.d( TAG, "acc status: %s", state == 1 );
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, state == 1 );
|
||||
int state = intent.getByteExtra( AccStatusReceiver.PARAM_ACC_STATUS, ACC_OFF );
|
||||
if ( state != ACC_OFF && state != ACC_ON && state != ACC_OFF_DELAY ) {
|
||||
return;
|
||||
}
|
||||
boolean accOn = state == ACC_ON;
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isAccOn() == accOn ) {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "acc status: %s", state );
|
||||
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, accOn );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
* @param context
|
||||
*/
|
||||
public void init( Context context ) {
|
||||
mContext = context;
|
||||
|
||||
if ( mContext != null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mContext = context.getApplicationContext();
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
|
||||
// 长连接
|
||||
|
||||
Reference in New Issue
Block a user