merge
This commit is contained in:
@@ -5,11 +5,7 @@ import android.content.Context;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
|
||||
/**
|
||||
@@ -25,20 +21,12 @@ public class MarkerServiceHandler {
|
||||
private static IMogoServiceApis sApis;
|
||||
|
||||
private static IMogoStatusManager sMogoStatusManager;
|
||||
private static IMogoAnalytics sMogoAnalytics;
|
||||
private static IMogoRegisterCenter sRegisterCenter;
|
||||
private static IMogoDataManager sDataManager;
|
||||
private static IMogoIntentManager sIntentManager;
|
||||
private static IMogoFragmentManager sFragmentManager;
|
||||
|
||||
public static synchronized void init(final Context context) {
|
||||
sApis = MogoApisHandler.getInstance().getApis();
|
||||
sMogoStatusManager = sApis.getStatusManagerApi();
|
||||
sMogoAnalytics = sApis.getAnalyticsApi();
|
||||
sRegisterCenter = sApis.getRegisterCenterApi();
|
||||
sDataManager = sApis.getDataManagerApi();
|
||||
sIntentManager = sApis.getIntentManagerApi();
|
||||
sFragmentManager = sApis.getFragmentManagerApi();
|
||||
MapMarkerManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
@@ -50,23 +38,8 @@ public class MarkerServiceHandler {
|
||||
return sMogoStatusManager;
|
||||
}
|
||||
|
||||
public static IMogoAnalytics getMogoAnalytics() {
|
||||
return sMogoAnalytics;
|
||||
}
|
||||
|
||||
public static IMogoRegisterCenter getRegisterCenter() {
|
||||
return sRegisterCenter;
|
||||
}
|
||||
|
||||
public static IMogoIntentManager getIntentManager() {
|
||||
return sIntentManager;
|
||||
}
|
||||
|
||||
public static IMogoFragmentManager getFragmentManager() {
|
||||
return sFragmentManager;
|
||||
}
|
||||
|
||||
public static IMogoDataManager getDataManager() {
|
||||
return sDataManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.service.routeoverlay.MogoRouteOverlayManager;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
@@ -57,31 +51,6 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppPackage() {
|
||||
return null;
|
||||
@@ -98,8 +67,6 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
MogoServices.getInstance().preInit( context );
|
||||
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
|
||||
MogoRouteOverlayManager.getInstance(context).init();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
}, 5_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,50 +5,25 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_OLD
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.map.IDestroyable;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.service.handler.MainLooperHandler;
|
||||
import com.mogo.module.service.handler.RefreshWorkThreadHandler;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
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.module.service.refresh.RefreshObject;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -67,17 +42,9 @@ import java.util.List;
|
||||
* 4. 用户交互语音导致地图视图移动,缩放,不触发刷新
|
||||
*/
|
||||
public class MogoServices implements IMogoMapListener,
|
||||
IMogoLocationListener,
|
||||
IMogoNaviListener,
|
||||
IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack,
|
||||
FragmentStackTransactionListener,
|
||||
IMogoCarLocationChangedListener2,
|
||||
IDestroyable {
|
||||
|
||||
private boolean mInternalUnWakeupRegisterStatus = false;
|
||||
|
||||
|
||||
private MogoServices() {
|
||||
// private constructor
|
||||
}
|
||||
@@ -92,201 +59,32 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private static final String TAG = "MogoServices";
|
||||
|
||||
/**
|
||||
* 自动刷新策略
|
||||
*/
|
||||
private final AutoRefreshStrategy mAutoRefreshStrategy = new AutoRefreshStrategy();
|
||||
/**
|
||||
* 手动刷新策略
|
||||
*/
|
||||
private final CustomRefreshStrategy mCustomRefreshStrategy = new CustomRefreshStrategy();
|
||||
|
||||
private MogoLatLng mLastAutoRefreshLocation = null;
|
||||
|
||||
/**
|
||||
* 是否已计算出地图显示状态
|
||||
*/
|
||||
private boolean mIsMapStatusOk = false;
|
||||
|
||||
/**
|
||||
* 地图显示是横屏还是竖屏:根据地图右上角和左下角坐标计算
|
||||
*/
|
||||
private boolean mIsVertical = false;
|
||||
|
||||
private MogoReceiver mAIAssistReceiver;
|
||||
private RefreshModel mRefreshModel;
|
||||
|
||||
private float mLastZoomLevel = 0;
|
||||
private long mRefreshRemainingTime = Long.MAX_VALUE;
|
||||
// 上次手动操作的中心点坐标
|
||||
private MogoLatLng mLastCustomRefreshCenterLocation;
|
||||
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
private IMogoFragmentManager mFragmentManager;
|
||||
private IMogoRegisterCenter mRegisterCenter;
|
||||
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
*/
|
||||
private boolean mIsCameraInited = true;
|
||||
|
||||
/**
|
||||
* 是否针对第一次请求失败的情况(开机请求、地库长时间没网络)
|
||||
* <p>
|
||||
* 说明:第一次地位成功,因为网络问题,导致请求失败,则在其他策略请求之前,尝试10s请求一次。
|
||||
*/
|
||||
private boolean mLoopRequest = false;
|
||||
|
||||
private final Handler mHandler = new MainLooperHandler(Looper.getMainLooper()) {
|
||||
|
||||
@Override
|
||||
protected void handleRefreshDecrease(Message msg) {
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
invokeAutoRefreshStrategy();
|
||||
return;
|
||||
}
|
||||
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
|
||||
if (mRefreshRemainingTime <= 0) {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "move to center and refresh data.");
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed(msg.what, ServiceConst.DECREASE_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleLoopRequestMessage(Message msg) {
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
return;
|
||||
}
|
||||
if (mLoopRequest) {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "补偿刷新触发");
|
||||
invokeAutoRefresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 自动刷新:锁车、缩放比例:16、半径 2KM
|
||||
*/
|
||||
private void invokeAutoRefresh() {
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
return;
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false);
|
||||
MogoMapUIController.getInstance().changeZoom(ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL);
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
notifyRefreshData(mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback);
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
||||
/**
|
||||
* 地图视图西南角坐标
|
||||
*/
|
||||
private MogoLatLng mCameraSouthWestPosition;
|
||||
|
||||
/**
|
||||
* 地图视图东北角坐标
|
||||
*/
|
||||
private MogoLatLng mCameraNorthEastPosition;
|
||||
|
||||
/**
|
||||
* 手动刷新回调
|
||||
*/
|
||||
private final RefreshCallback mCustomRefreshCallback = new RefreshCallback<MarkerResponse>() {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
MapMarkerManager.getInstance().onSyncMarkerResponse(o);
|
||||
mLoopRequest = false;
|
||||
// 用户手动操作地图刷新成功后,设置状态为 true,引发延时策略
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 自动刷新回调
|
||||
*/
|
||||
private final RefreshCallback mAutoRefreshCallback = new RefreshCallback<MarkerResponse>() {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
MapMarkerManager.getInstance().onSyncMarkerResponse(o);
|
||||
mLoopRequest = false;
|
||||
invokeAutoRefreshStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
if (mLoopRequest) {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "onFail and loop");
|
||||
mHandler.sendEmptyMessageDelayed(ServiceConst.MSG_LOOP_REQUEST, ServiceConst.LOOP_INTERVAL);
|
||||
} else {
|
||||
invokeAutoRefreshStrategy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void invokeAutoRefreshStrategy() {
|
||||
restartAutoRefreshAtTime(mAutoRefreshStrategy.getInterval());
|
||||
}
|
||||
|
||||
private Handler mThreadHandler;
|
||||
|
||||
private final IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() {
|
||||
|
||||
};
|
||||
|
||||
|
||||
public void preInit(Context context) {
|
||||
mContext = context;
|
||||
|
||||
mRefreshModel = new RefreshModel(context);
|
||||
mStatusManager = MarkerServiceHandler.getMogoStatusManager();
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, statusChangedListener);
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.MAIN_PAGE_RESUME, statusChangedListener);
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.SEEK_HELPING, statusChangedListener);
|
||||
IMogoStatusManager mStatusManager = MarkerServiceHandler.getMogoStatusManager();
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, statusChangedListener);
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.VR_MODE, statusChangedListener);
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.TOP_VIEW, statusChangedListener);
|
||||
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.MAIN_PAGE_IS_BACKGROUND, statusChangedListener);
|
||||
mStatusManager.setAIAssistReady(TAG, AIAssist.getInstance(mContext).hasFlush());
|
||||
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
|
||||
initWorkThread();
|
||||
|
||||
registerMogoReceiver(context);
|
||||
registerInternalUnWakeupWords();
|
||||
|
||||
mRegisterCenter = MarkerServiceHandler.getRegisterCenter();
|
||||
mRegisterCenter.registerMogoMapListener(ServiceConst.TYPE, this);
|
||||
mRegisterCenter.registerMogoLocationListener(ServiceConst.TYPE, this);
|
||||
mRegisterCenter.registerMogoNaviListener(ServiceConst.TYPE, this);
|
||||
mRegisterCenter.registerCarLocationChangedListener(ServiceConst.TYPE, this);
|
||||
|
||||
mIntentManager = MarkerServiceHandler.getIntentManager();
|
||||
mIntentManager.registerIntentListener(MogoReceiver.ACTION_VOICE_UI, this);
|
||||
mIntentManager.registerIntentListener(ServiceConst.COMMAND_MY_LOCATION, this);
|
||||
mIntentManager.registerIntentListener(MogoReceiver.ACTION_VOICE_READY, this);
|
||||
mIntentManager.registerIntentListener(MogoReceiver.ACTION_MOCK, this);
|
||||
mIntentManager.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, this);
|
||||
|
||||
mFragmentManager = MarkerServiceHandler.getFragmentManager();
|
||||
|
||||
mFragmentManager.addMainFragmentStackTransactionListener(this);
|
||||
|
||||
Intent intent = new Intent("com.freedom.ser.ACTION");
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mContext.sendBroadcast(intent);
|
||||
@@ -296,36 +94,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
mThreadHandler = new RefreshWorkThreadHandler(WorkThreadHandler.getInstance().getLooper()) {
|
||||
@Override
|
||||
protected void handleMapChangedMessage(Message msg) {
|
||||
if (msg.obj instanceof RefreshObject) {
|
||||
RefreshObject ro = ((RefreshObject) msg.obj);
|
||||
if (invokeRefreshWhenTranslationByUser(ro.mLonLat)) {
|
||||
notifyRefreshData(ro.mLonLat, ro.mRadius, ro.mCallback);
|
||||
mLastCustomRefreshCenterLocation = ro.mLonLat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleRequestDataMessage(Message msg) {
|
||||
if (msg.obj instanceof RefreshObject) {
|
||||
RefreshObject ro = ((RefreshObject) msg.obj);
|
||||
if (ro.mLonLat == null) {
|
||||
invokeAutoRefreshStrategy();
|
||||
CallerLogger.INSTANCE.w(M_OLD_OTHER + TAG, "lonLat is null.");
|
||||
return;
|
||||
}
|
||||
//请求大而全数据,刷新地图POI
|
||||
mRefreshModel.refreshExplorerWayData(ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback);
|
||||
CallerLogger.INSTANCE.i(M_OLD_OTHER + TAG, "刷新半径 = " + ro.mRadius + ", 点 = " + ro.mLonLat + " , zoomLevel = " + mLastZoomLevel + ", amount = " + ro.mAmount);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void registerMogoReceiver(Context context) {
|
||||
if (context == null) {
|
||||
return;
|
||||
@@ -358,250 +126,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
initMapStatus();
|
||||
}
|
||||
|
||||
private void initMapStatus() {
|
||||
if (mIsMapStatusOk) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
float width = getMapCameraFactWidth();
|
||||
float height = getMapCameraFactHeight();
|
||||
mIsVertical = width < height;
|
||||
mIsMapStatusOk = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图视图对应的实际宽度
|
||||
*/
|
||||
private float getMapCameraFactWidth() {
|
||||
try {
|
||||
return Utils.calculateLineDistance(mCameraNorthEastPosition, new MogoLatLng(mCameraNorthEastPosition.lat, mCameraSouthWestPosition.lon));
|
||||
} catch (Exception e) {
|
||||
return ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图视图对应的实际高度
|
||||
*/
|
||||
private float getMapCameraFactHeight() {
|
||||
try {
|
||||
return Utils.calculateLineDistance(mCameraSouthWestPosition, new MogoLatLng(mCameraNorthEastPosition.lat, mCameraSouthWestPosition.lon));
|
||||
} catch (Exception e) {
|
||||
return ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(MotionEvent motionEvent) {
|
||||
switch (motionEvent.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (mLastZoomLevel == 0) {
|
||||
mLastZoomLevel = MogoMapUIController.getInstance().getZoomLevel();
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
restartAutoRefreshAtTime(ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT, false);
|
||||
mThreadHandler.removeMessages(ServiceConst.MSG_LOCK_CAR);
|
||||
mThreadHandler.sendEmptyMessageDelayed(ServiceConst.MSG_LOCK_CAR, ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAutoRefreshStrategy() {
|
||||
stopAutoRefreshStrategy(true);
|
||||
}
|
||||
|
||||
private void stopAutoRefreshStrategy(boolean stopOnlineCarRefresh) {
|
||||
mHandler.removeMessages(ServiceConst.MSG_TYPE_REFRESH_DECREASE);
|
||||
if (stopOnlineCarRefresh) {
|
||||
MapMarkerManager.getInstance().stopAutoRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap(boolean isLock) {
|
||||
mThreadHandler.removeMessages(ServiceConst.MSG_LOCK_CAR);
|
||||
if (!isLock) {
|
||||
mThreadHandler.sendEmptyMessageDelayed(ServiceConst.MSG_LOCK_CAR, ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged(MogoLatLng latLng, float zoom, float tilt, float bearing) {
|
||||
|
||||
MapMarkerManager.getInstance().syncLocation(latLng.lon, latLng.lat);
|
||||
|
||||
if (mIsCameraInited) {
|
||||
mLastZoomLevel = zoom;
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mIsCameraInited = false;
|
||||
initMapStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
// 部分非用户操作导致地图视图变化:绘线、圈点等不触发用户刷新
|
||||
// 消费状态
|
||||
if (mStatusManager.isUserInteracted()) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// v2x // adas 状态下不做任何操作
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// 手动刷新触发
|
||||
if (mLastZoomLevel - zoom > mCustomRefreshStrategy.getZoomOutLevel()) {
|
||||
// 缩放级别缩小
|
||||
notifyRefreshData(latLng, getQueryRadius(), mCustomRefreshCallback);
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
} else if (mLastZoomLevel - zoom < 0) {
|
||||
mLastZoomLevel = zoom;
|
||||
} else if (mLastZoomLevel == zoom) {
|
||||
// 手动平移
|
||||
Message msg = Message.obtain();
|
||||
msg.what = ServiceConst.MSG_MAP_CHANGED;
|
||||
msg.obj = new RefreshObject(mCustomRefreshCallback, getQueryRadius(), latLng, 0);
|
||||
mThreadHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private int getQueryRadius() {
|
||||
mCameraSouthWestPosition = MogoMapUIController.getInstance().getCameraSouthWestPosition();
|
||||
mCameraNorthEastPosition = MogoMapUIController.getInstance().getCameraNorthEastPosition();
|
||||
int radius;
|
||||
if (mIsVertical) {
|
||||
radius = ((int) (getMapCameraFactWidth() / 2));
|
||||
} else {
|
||||
radius = ((int) (getMapCameraFactHeight() / 2));
|
||||
}
|
||||
return Math.max(radius, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平移地图刷新策略
|
||||
*/
|
||||
private boolean invokeRefreshWhenTranslationByUser(MogoLatLng latLng) {
|
||||
try {
|
||||
float factor;
|
||||
if (mIsVertical) {
|
||||
factor = getMapCameraFactWidth();
|
||||
} else {
|
||||
factor = getMapCameraFactHeight();
|
||||
}
|
||||
if (factor == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance(latLng, mLastCustomRefreshCenterLocation);
|
||||
return distance > (factor / 2);
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(M_OLD_OTHER + TAG, "invokeRefreshWhenTranslationByUser warming : " + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageLaunched()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageOnResume()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 自动刷新触发
|
||||
final MogoLatLng point = new MogoLatLng(location.getLatitude(), location.getLongitude());
|
||||
if (mLastAutoRefreshLocation == null) {
|
||||
startFirstLocationRequest(point);
|
||||
return;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance(mLastAutoRefreshLocation, point);
|
||||
if (distance > mAutoRefreshStrategy.getDistance()) {
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false);
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
MogoMapUIController.getInstance().changeZoom(ServiceConst.DEFAULT_ZOOM_LEVEL);
|
||||
mLastAutoRefreshLocation = point;
|
||||
notifyRefreshData(mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次定位成功后,执行道路事件的刷新
|
||||
*
|
||||
* @param point {@link MogoLatLng}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新数据
|
||||
*/
|
||||
private void notifyRefreshData(MogoLatLng latLng, int radius, RefreshCallback callback) {
|
||||
if (!mStatusManager.isMainPageLaunched()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageOnResume()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = 20;
|
||||
|
||||
Message msg = Message.obtain();
|
||||
msg.what = ServiceConst.MSG_REQUEST_DATA;
|
||||
msg.obj = new RefreshObject(callback, radius, latLng, amount);
|
||||
if (mThreadHandler != null) {
|
||||
mThreadHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void restartAutoRefreshAtTime(long time) {
|
||||
restartAutoRefreshAtTime(time, true);
|
||||
}
|
||||
|
||||
public void clearAllData() {
|
||||
try {
|
||||
MogoMarkerManager.getInstance(mContext).removeMarkers();
|
||||
@@ -610,33 +134,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void restartAutoRefreshAtTime(long time, boolean stopOnlineCarRefresh) {
|
||||
if (time < 0) {
|
||||
CallerLogger.INSTANCE.w(M_OLD_OTHER + TAG, "refresh request case time < 0, set to 0 and go on.");
|
||||
time = 0;
|
||||
}
|
||||
stopAutoRefreshStrategy(stopOnlineCarRefresh);
|
||||
mRefreshRemainingTime = time;
|
||||
long delay = ServiceConst.DECREASE_INTERVAL;
|
||||
if (mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL) {
|
||||
delay = mRefreshRemainingTime;
|
||||
}
|
||||
if (time == 0) {
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed(ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshStrategy() {
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false);
|
||||
MogoMapUIController.getInstance().recoverLockMode();// 锁车代替移到中心点
|
||||
restartAutoRefreshAtTime(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived(String command, Intent intent) {
|
||||
|
||||
if (TextUtils.equals(command, ConnectivityManager.CONNECTIVITY_ACTION)
|
||||
&& NetworkUtils.isConnected(mContext)) {
|
||||
mIntentManager.unregisterIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, this);
|
||||
@@ -644,77 +143,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
IntentHandlerFactory.getInstance().handle(mContext, command, intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册桌面免唤醒指令
|
||||
*/
|
||||
public void registerInternalUnWakeupWords() {
|
||||
if (mInternalUnWakeupRegisterStatus) {
|
||||
return;
|
||||
}
|
||||
mInternalUnWakeupRegisterStatus = true;
|
||||
AIAssist.getInstance(mContext).registerUnWakeupCommand(ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, ServiceConst.CMD_UN_WAKEUP_WORDS_MY_LOCATION, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销桌面免唤醒指令
|
||||
*/
|
||||
public void unregisterInternalUnWakeupWords() {
|
||||
if (!mInternalUnWakeupRegisterStatus) {
|
||||
return;
|
||||
}
|
||||
mInternalUnWakeupRegisterStatus = false;
|
||||
AIAssist.getInstance(mContext).unregisterUnWakeupCommand(ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected(String cmd) {
|
||||
if (TextUtils.equals(ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, cmd)) {
|
||||
if (mStatusManager.isMainPageOnResume()) {
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
}
|
||||
} else if (TextUtils.equals(ServiceConst.CMD_BACK, cmd)) {
|
||||
mFragmentManager.clearAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransaction(int size) {
|
||||
if (size == 0) {
|
||||
MogoMapUIController.getInstance().showMyLocation(true);
|
||||
AIAssist.getInstance(mContext).unregisterUnWakeupCommand(ServiceConst.CMD_BACK);
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
} else {
|
||||
MogoMapUIController.getInstance().showMyLocation(false);
|
||||
AIAssist.getInstance(mContext).registerUnWakeupCommand(ServiceConst.CMD_BACK, ServiceConst.CMD_BACK_WORDS, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
if (DebugConfig.isIsScheduleCalculateNotHomeCompanyDistanceForPush()) {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "onStartNavi: scheduleCalculationNotHomeCompanyDistanceForPush");
|
||||
scheduleCalculationNotHomeCompanyDistanceForPush(1, ServiceConst.INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "onStartNavi: scheduleCalculationNotHomeCompanyDistanceForPush un support");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "onStopNavi: remove MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH msg");
|
||||
mHandler.removeMessages(ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 延时一分钟发起计算导航目的地推送策略
|
||||
*/
|
||||
public void scheduleCalculationNotHomeCompanyDistanceForPush(int time, long delay) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH;
|
||||
msg.arg1 = time;
|
||||
mHandler.sendMessageDelayed(msg, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "MogoServices do nothings.");
|
||||
@@ -723,14 +151,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private boolean mLastStatusIsVr = false;
|
||||
|
||||
public boolean isLastStatusIsVr() {
|
||||
return mLastStatusIsVr;
|
||||
}
|
||||
|
||||
public void setLastStatusIsVr(boolean lastStatusIsVr) {
|
||||
this.mLastStatusIsVr = lastStatusIsVr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged(EnumMapUI ui) {
|
||||
clearAllData();
|
||||
|
||||
@@ -18,31 +18,11 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String PATH_REFRESH_STRATEGY = "/strategy/refresh";
|
||||
|
||||
/**
|
||||
* 倒计时消息
|
||||
*/
|
||||
public static final int MSG_TYPE_REFRESH_DECREASE = 0x100;
|
||||
/**
|
||||
* 倒计时间隔
|
||||
*/
|
||||
public static final int DECREASE_INTERVAL = 10_000;
|
||||
|
||||
/**
|
||||
* 刷新失败补偿消息
|
||||
*/
|
||||
public static final int MSG_LOOP_REQUEST = 0x101;
|
||||
|
||||
/**
|
||||
* 刷新失败补偿时间间隔
|
||||
*/
|
||||
public static final int LOOP_INTERVAL = 10_000;
|
||||
|
||||
/**
|
||||
* 卡片 探路数据
|
||||
*/
|
||||
public static final String CARD_TYPE_ROAD_CONDITION = "CARD_TYPE_ROAD_CONDITION";
|
||||
|
||||
|
||||
/**
|
||||
* 卡片 用户数据
|
||||
*/
|
||||
@@ -53,74 +33,9 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String CARD_TYPE_NOVELTY = "CARD_TYPE_NOVELTY";
|
||||
|
||||
/**
|
||||
* 默认地图缩放比例
|
||||
*/
|
||||
public static final float DEFAULT_ZOOM_LEVEL = 16.0f;
|
||||
|
||||
/**
|
||||
* 默认地图锁车缩放比例
|
||||
*/
|
||||
public static final int DEFAULT_LOCK_CAR_ZOOM_LEVEL = 16;
|
||||
|
||||
/**
|
||||
* 自动刷新默认半径
|
||||
*/
|
||||
public static final int DEFAULT_AUTO_REFRESH_DATA_RADIUS = 2_000;
|
||||
|
||||
/**
|
||||
* 30 s
|
||||
*/
|
||||
public static final int DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT = 30 * 1_000;
|
||||
|
||||
/**
|
||||
* 所有卡片显示的每类点的最大数据量
|
||||
*/
|
||||
public static final int MAX_AMOUNT_ALL = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
/**
|
||||
* 地图变化消息
|
||||
*/
|
||||
public static final int MSG_MAP_CHANGED = 0x200;
|
||||
|
||||
/**
|
||||
* 请求刷新数据
|
||||
*/
|
||||
public static final int MSG_REQUEST_DATA = 0x201;
|
||||
|
||||
/**
|
||||
* 锁车消息
|
||||
*/
|
||||
public static final int MSG_LOCK_CAR = 0x202;
|
||||
|
||||
/**
|
||||
* 回到自车
|
||||
*/
|
||||
public static final String COMMAND_MY_LOCATION = "com.zhidao.desk.backToMyLocation";
|
||||
|
||||
public static final String CMD_UN_WAKEUP_MY_LOCATION = "CMD_UN_WAKEUP_MY_LOCATION";
|
||||
public static final String[] CMD_UN_WAKEUP_WORDS_MY_LOCATION = new String[]{
|
||||
"回到我的位置",
|
||||
"返回我的位置",
|
||||
"定位我的位置"
|
||||
};
|
||||
|
||||
public static final String CMD_BACK = "back";
|
||||
public static final String[] CMD_BACK_WORDS = new String[]{"关闭", "返回"};
|
||||
|
||||
public static final int ONLINE_SEARCH_LIMIT = 20;
|
||||
public static final int ONLINE_SEARCH_RADIUS = 2_000;
|
||||
|
||||
/**
|
||||
* 导航开始后,延时1分钟开启推送策略
|
||||
*/
|
||||
public static final int MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 0x301;
|
||||
|
||||
/**
|
||||
* 延时1分钟开启推送策略
|
||||
*/
|
||||
public static final long INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 60 * 1_000L;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
@@ -19,44 +16,14 @@ public abstract class StatusChangedAdapter implements IMogoStatusChangedListener
|
||||
|
||||
private static final String TAG = "StatusChangedAdapter";
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
private boolean mIsFirstAccOn = true;
|
||||
|
||||
@Override
|
||||
public final void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
switch (descriptor) {
|
||||
case USER_INTERACTED:
|
||||
onUserInteracted(isTrue);
|
||||
break;
|
||||
case MAIN_PAGE_RESUME:
|
||||
onMainPageResumeStatusChanged(isTrue);
|
||||
break;
|
||||
case ACC_STATUS:
|
||||
onAccStatusChanged(isTrue);
|
||||
break;
|
||||
case TOP_VIEW:
|
||||
onTopViewStatusChanged(isTrue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onUserInteracted(boolean userInteracted) {
|
||||
if (userInteracted) {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime(ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT);
|
||||
}
|
||||
}
|
||||
|
||||
public void onMainPageResumeStatusChanged(boolean resume) {
|
||||
if (resume) {
|
||||
MogoServices.getInstance().registerInternalUnWakeupWords();
|
||||
if (!mIsMainPageFirstResume) {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime(2_000L);
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
} else {
|
||||
MogoServices.getInstance().unregisterInternalUnWakeupWords();
|
||||
MogoServices.getInstance().stopAutoRefreshStrategy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,24 +33,8 @@ public abstract class StatusChangedAdapter implements IMogoStatusChangedListener
|
||||
mIsFirstAccOn = false;
|
||||
return;
|
||||
}
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).removeMarkers();
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
MogoServices.getInstance().refreshStrategy();
|
||||
}, 3_000L);
|
||||
} else {
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).removeMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
public void onTopViewStatusChanged(boolean visible) {
|
||||
if (visible) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MapMarkerManager.getInstance().onCloseCurrentSelectedMarker();
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "onTopViewStatusChanged exception : " + e);
|
||||
}
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).removeMarkers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.mogo.module.service.datamanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.service.datamanager.IMogoDataChanged2Listener;
|
||||
import com.mogo.service.datamanager.IMogoDataChangedListener;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-11
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoDataHandler implements IMogoDataManager {
|
||||
|
||||
private static final String TAG = "MogoDataHandler";
|
||||
|
||||
private Map<String, List<IMogoDataChangedListener>> mListeners = new HashMap<>();
|
||||
|
||||
private MogoDataHandler() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final MogoDataHandler INSTANCE = new MogoDataHandler();
|
||||
}
|
||||
|
||||
public static MogoDataHandler getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerDataListener(String tag, IMogoDataChangedListener listener) {
|
||||
if (listener == null || TextUtils.isEmpty(tag)) {
|
||||
return;
|
||||
}
|
||||
if (!mListeners.containsKey(tag) || mListeners.get(tag) == null) {
|
||||
mListeners.put(tag, new ArrayList<>());
|
||||
}
|
||||
mListeners.get(tag).add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterListener(String tag, IMogoDataChangedListener listener) {
|
||||
if (listener == null || TextUtils.isEmpty(tag)) {
|
||||
return;
|
||||
}
|
||||
if (mListeners.containsKey(tag) && mListeners.get(tag) != null) {
|
||||
mListeners.get(tag).remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDataFrom(String module, Object object) {
|
||||
if (module == null || mListeners.get(module) == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Iterator<IMogoDataChangedListener> iterator = mListeners.get(module).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoDataChangedListener listener = iterator.next();
|
||||
if (listener instanceof IMogoDataChanged2Listener) {
|
||||
((IMogoDataChanged2Listener) listener).onDataRemoved(module, object);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "removeDataFrom exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData2(String module, Object object) {
|
||||
if (module == null || mListeners.get(module) == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Iterator<IMogoDataChangedListener> iterator = mListeners.get(module).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoDataChangedListener listener = iterator.next();
|
||||
if (listener instanceof IMogoDataChanged2Listener) {
|
||||
((IMogoDataChanged2Listener) listener).onDataAdded(module, object);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "addData2 exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncData(String module, Object object) {
|
||||
if (module == null || mListeners.get(module) == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Iterator<IMogoDataChangedListener> iterator = mListeners.get(module).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoDataChangedListener listener = iterator.next();
|
||||
if (listener != null) {
|
||||
listener.onDataSetChanged(object);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "syncData exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void invoke(String tag, Object data) {
|
||||
syncData(tag, data);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.mogo.module.service.datamanager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.service.datamanager.IMogoDataChangedListener;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-11
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_DATA_MANAGER )
|
||||
public class MogoDataManager implements IMogoDataManager {
|
||||
|
||||
@Override
|
||||
public void registerDataListener( String tag, IMogoDataChangedListener listener ) {
|
||||
MogoDataHandler.getInstance().registerDataListener( tag, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterListener( String tag, IMogoDataChangedListener listener ) {
|
||||
MogoDataHandler.getInstance().unregisterListener( tag, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData2( String module, Object object ) {
|
||||
MogoDataHandler.getInstance().addData2( module, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDataFrom( String module, Object object ) {
|
||||
MogoDataHandler.getInstance().removeDataFrom( module, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncData( String module, Object object ) {
|
||||
MogoDataHandler.getInstance().syncData( module, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
MogoDataHandler.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.module.service.handler;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
public abstract class MainLooperHandler extends Handler {
|
||||
|
||||
private static final String TAG = "MainLooperHandler";
|
||||
|
||||
public MainLooperHandler( Looper looper ) {
|
||||
super( looper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
|
||||
switch ( msg.what ) {
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
handleRefreshDecrease( msg );
|
||||
break;
|
||||
case ServiceConst.MSG_LOOP_REQUEST:
|
||||
handleLoopRequestMessage( msg );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void handleRefreshDecrease( Message msg );
|
||||
|
||||
protected abstract void handleLoopRequestMessage( Message msg );
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.mogo.module.service.handler;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
abstract class RefreshWorkThreadHandler extends Handler {
|
||||
|
||||
private static final String TAG = "RefreshWorkThreadHandler";
|
||||
|
||||
public RefreshWorkThreadHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == ServiceConst.MSG_MAP_CHANGED) {
|
||||
try {
|
||||
handleMapChangedMessage(msg);
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "handleMapChangedMessage exception : " + e);
|
||||
}
|
||||
} else if (msg.what == ServiceConst.MSG_REQUEST_DATA) {
|
||||
try {
|
||||
handleRequestDataMessage(msg);
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "handleRequestDataMessage exception : " + e);
|
||||
}
|
||||
} else if (msg.what == ServiceConst.MSG_LOCK_CAR) {
|
||||
try {
|
||||
handleLockCarMessage(msg);
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, "handleLockCarMessage exception : " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void handleMapChangedMessage(Message msg);
|
||||
|
||||
protected abstract void handleRequestDataMessage(Message msg);
|
||||
|
||||
protected void handleLockCarMessage(Message msg) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
return;
|
||||
}
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setUserInteractionStatus( TAG, true, false );
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ public class IntentHandlerFactory {
|
||||
private IntentHandlerFactory() {
|
||||
// private constructor
|
||||
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_UI, new VoiceUiIntentHandler() );
|
||||
mHandlers.put( Intent.ACTION_POWER_CONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
mHandlers.put( Intent.ACTION_POWER_DISCONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
|
||||
@@ -235,7 +235,6 @@ public class MockIntentHandler implements IntentHandler {
|
||||
.autoManager(false);
|
||||
int duration = intent.getIntExtra("duration", 30);
|
||||
IMogoMarker marker = MogoMarkerManager.getInstance(context).addMarker(TAG, options);
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
|
||||
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
|
||||
MogoMapUIController.getInstance().moveToCenter(mogoLatLngs.get(0));
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 语音指令:定位我的位置等处理
|
||||
*/
|
||||
public class MyLocationHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
} else {
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MogoMapUIController.getInstance().recoverLockMode();
|
||||
}, 2_000L );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import android.text.TextUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadPoolService;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -17,12 +19,10 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.RoadConditionDrawer;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.drawer.marker.OnlineCarMarkerView;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
@@ -33,14 +33,7 @@ import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -57,11 +50,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
private IMogoMarker mLastCheckMarker;
|
||||
private static MapMarkerManager mMarkerManager;
|
||||
|
||||
// 记录上次请求数据,切换卡片时做数据处理
|
||||
private MarkerCardResult mLastDataResult;
|
||||
|
||||
private RefreshModel mRefreshModel;
|
||||
private MogoLatLng mCarLatLng;
|
||||
// 平滑移动事件间隔(单位:秒)
|
||||
private static final int SMOOTH_DURATION = 15;
|
||||
|
||||
@@ -79,18 +68,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
return mMarkerManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化大而全的 Marker 管理
|
||||
*
|
||||
* @param context 上下文对象
|
||||
*/
|
||||
public void init(Context context) {
|
||||
|
||||
if (mContext != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mContext = context.getApplicationContext();
|
||||
mRefreshModel = new RefreshModel(mContext);
|
||||
CloudPoiManager.getInstance().updateFromConfig(context);
|
||||
@@ -106,24 +92,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
if (marker.getObject() instanceof MarkerShowEntity) {
|
||||
final String sn = MarkerDrawer.getInstance().getCarSnFromMarker(marker);
|
||||
if (TextUtils.isEmpty(sn)) {
|
||||
return false;
|
||||
}
|
||||
properties.put("sn", sn);
|
||||
if (((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerExploreWay) {
|
||||
MarkerExploreWay exploreWay = (MarkerExploreWay) ((MarkerShowEntity) marker.getObject()).getBindObj();
|
||||
properties.put("dbid", exploreWay.getInfoId());
|
||||
properties.put("type", exploreWay.getPoiType());
|
||||
} else if (((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerOnlineCar) {
|
||||
properties.put("type", "10000");
|
||||
}
|
||||
}
|
||||
MarkerServiceHandler.getMogoAnalytics().track("v2x_road_click", properties);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -145,7 +113,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
closeMarker(mLastCheckMarker);
|
||||
}
|
||||
|
||||
// 将当前的Marker设置为选中
|
||||
openMarker(marker);
|
||||
return true;
|
||||
@@ -183,7 +150,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
}
|
||||
}
|
||||
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
|
||||
MogoMapUIController.getInstance().moveToCenter(mogoMarker.getPosition(), true);
|
||||
}
|
||||
}
|
||||
@@ -238,77 +204,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制Marker
|
||||
public synchronized void drawMapMarker(MarkerResponse response) {
|
||||
|
||||
if (response == null || response.getResult() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
|
||||
mLastDataResult = response.getResult();
|
||||
UiThreadHandler.post(this::dispatchDataToBiz);
|
||||
|
||||
drawMarkerByCurrentType(mLastDataResult);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型绘制
|
||||
*
|
||||
* @param markerCardResult
|
||||
*/
|
||||
private synchronized void drawMarkerByCurrentType(MarkerCardResult markerCardResult) {
|
||||
if (markerCardResult == null) {
|
||||
return;
|
||||
}
|
||||
if (MogoMapUIController.getInstance().getCurrentMapVisualAngle().isLongSight()) {
|
||||
return;
|
||||
}
|
||||
drawAllMarker(markerCardResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制所有数据
|
||||
*
|
||||
* @param markerCardResult
|
||||
*/
|
||||
private void drawAllMarker(MarkerCardResult markerCardResult) {
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
RoadConditionDrawer.getInstance().drawRoadConditionMarker(exploreWayList, ServiceConst.MAX_AMOUNT_ALL, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发数据到各个业务模块
|
||||
* <p>
|
||||
* 仅在数据刷新的时候分发
|
||||
*/
|
||||
private void dispatchDataToBiz() {
|
||||
if (mLastDataResult == null) {
|
||||
return;
|
||||
}
|
||||
List<MarkerExploreWay> exploreWayList = mLastDataResult.getExploreWay();
|
||||
dispatchDataToBis(ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList == null ? new ArrayList<>() : exploreWayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据分发
|
||||
*
|
||||
* @param biz
|
||||
* @param object
|
||||
*/
|
||||
private void dispatchDataToBis(String biz, Object object) {
|
||||
if (TextUtils.isEmpty(biz)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MarkerServiceHandler.getDataManager().syncData(biz, object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
|
||||
*
|
||||
@@ -323,44 +218,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步绘制大而全的数据 marker
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
public void onSyncMarkerResponse(MarkerResponse response) {
|
||||
if (ignoreDrawRequest()) {
|
||||
return;
|
||||
}
|
||||
runOnTargetThread(() -> {
|
||||
drawMapMarker(response);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前地图中心点坐标
|
||||
*
|
||||
* @param lon
|
||||
* @param lat
|
||||
*/
|
||||
public void syncLocation(double lon, double lat) {
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getOnlineCarDataImpl(mCarLatLng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
private final Runnable runnable = () -> {
|
||||
MogoLocation location = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
if (location != null) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(location.getLatitude(), location.getLongitude());
|
||||
getOnlineCarDataImpl(mogoLatLng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 移除绘制
|
||||
*/
|
||||
public void stopAutoRefresh() {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索在线车辆
|
||||
*
|
||||
@@ -376,8 +241,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
boolean onlyFocus,
|
||||
boolean onlySameCity,
|
||||
int limit,
|
||||
int radius,
|
||||
boolean fitBounds) {
|
||||
int radius) {
|
||||
|
||||
if (DebugConfig.isDebug()) {
|
||||
if (!DebugConfig.isRequestOnlineCarData()) {
|
||||
@@ -385,10 +249,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (mCarLatLng == null) {
|
||||
mCarLatLng = latLng;
|
||||
}
|
||||
|
||||
if (latLng == null) {
|
||||
return;
|
||||
}
|
||||
@@ -420,29 +280,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
}
|
||||
|
||||
runOnTargetThread(() -> {
|
||||
trackData(size);
|
||||
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
private void trackData(int size) {
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("type", "10000");
|
||||
object.put("num", size);
|
||||
array.put(object);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (array.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("data", array.toString());
|
||||
MarkerServiceHandler.getMogoAnalytics().track("v2x_data_get", properties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -481,13 +321,4 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
|
||||
ThreadPoolService.execute(runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭当前点击过的 marker
|
||||
*/
|
||||
public void onCloseCurrentSelectedMarker() {
|
||||
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
|
||||
closeMarker(mLastCheckMarker);
|
||||
mLastCheckMarker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,6 @@ import retrofit2.http.POST;
|
||||
* 接口描述
|
||||
*/
|
||||
public interface RefreshApiService {
|
||||
/**
|
||||
* 大而全
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync")
|
||||
Observable<MarkerResponse> refreshDataSync(@FieldMap Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* 周边在线车辆
|
||||
|
||||
@@ -37,51 +37,6 @@ public class RefreshModel {
|
||||
this.mRefreshApiService = MoGoRetrofitFactory.getInstance(HostConst.LAUNCHER_SNAPSHOT_HOST).create(RefreshApiService.class);
|
||||
}
|
||||
|
||||
public void refreshExplorerWayData(MogoLatLng latLng, int radius, int limit, final RefreshCallback callback) {
|
||||
if (mRefreshApiService != null) {
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.viewPush = true;
|
||||
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
|
||||
|
||||
String data = GsonUtil.jsonFromObject(refreshBody);
|
||||
query.put("data", data);
|
||||
|
||||
mRefreshApiService.refreshDataSync(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
if (callback != null) {
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询车辆 及路线
|
||||
*
|
||||
|
||||
@@ -35,9 +35,6 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_MOCK = "com.mogo.mock";
|
||||
|
||||
//车辆监控
|
||||
public static final String ACTION_CHECK_VEHICLE_MONITORING = "ACTION_CHECK_VEHICLE_MONITORING";
|
||||
|
||||
private final IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.mogo.module.service.refresh;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
* <p>
|
||||
* 自动刷新策略
|
||||
*/
|
||||
public class AutoRefreshStrategy {
|
||||
|
||||
public static final long ONE_MINUTE = 60 * 1_000L;
|
||||
|
||||
/**
|
||||
* 距离(米)
|
||||
*/
|
||||
private int distance = 1_000;
|
||||
|
||||
/**
|
||||
* 时间间距(s)
|
||||
*/
|
||||
private long interval = 3 * ONE_MINUTE / 6;
|
||||
|
||||
/**
|
||||
* 用户打断后的延时(s)【2.0.2后不再延时】
|
||||
*/
|
||||
private long interruptInterval = 0 * ONE_MINUTE;
|
||||
|
||||
/**
|
||||
* 距离(米)
|
||||
*/
|
||||
public int getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间间距(s)
|
||||
*/
|
||||
public long getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户打断后的延时
|
||||
*/
|
||||
public long getInterruptInterval() {
|
||||
return interruptInterval;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mogo.module.service.refresh;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
* <p>
|
||||
* 手动刷新策略
|
||||
*/
|
||||
public class CustomRefreshStrategy {
|
||||
|
||||
/**
|
||||
* 缩小倍数
|
||||
*/
|
||||
private float zoomOutLevel = 2;
|
||||
|
||||
public float getZoomOutLevel() {
|
||||
return zoomOutLevel;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.mogo.module.service.refresh;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-11
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class RefreshObject {
|
||||
|
||||
public final RefreshCallback mCallback;
|
||||
public final int mRadius;
|
||||
public final MogoLatLng mLonLat;
|
||||
public final int mAmount;
|
||||
|
||||
public RefreshObject( RefreshCallback callback, int radius, MogoLatLng lonLat, int amount ) {
|
||||
this.mCallback = callback;
|
||||
this.mRadius = radius;
|
||||
this.mLonLat = lonLat;
|
||||
this.mAmount = amount;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user