opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -16,12 +16,10 @@ import android.view.animation.Interpolator;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.CustomRenderer;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.LatLngBoundsCreator;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MyLocationStyle;
|
||||
import com.amap.api.maps.model.Poi;
|
||||
@@ -37,7 +35,6 @@ import com.amap.api.navi.model.NaviInfo;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.impl.amap.hook.BnHooker;
|
||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.impl.amap.message.AMapMessageListener;
|
||||
@@ -54,11 +51,6 @@ import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import retrofit2.http.HEAD;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
@@ -76,7 +68,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
AMapNaviViewListener,
|
||||
AMapMessageListener,
|
||||
AMap.OnCameraChangeListener,
|
||||
AMap.OnMyLocationChangeListener{
|
||||
AMap.OnMyLocationChangeListener {
|
||||
|
||||
private static final String TAG = "AMapNaviViewWrapper";
|
||||
|
||||
@@ -84,6 +76,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
private IMogoMap mIMap;
|
||||
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
private EnumMapUI mCurrentUIMode;
|
||||
|
||||
public AMapNaviViewWrapper( AMapNaviView mapView ) {
|
||||
this.mMapView = mapView;
|
||||
@@ -158,7 +151,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
mMapView.setRouteOverlayVisible( false );
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
setUIMode(EnumMapUI.CarUp_2D, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,16 +399,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
options.setTilt( 0 );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
break;
|
||||
case CarUp_3D:
|
||||
options.setTilt( 60 );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
break;
|
||||
case NorthUP_2D:
|
||||
options.setTilt( 0 );
|
||||
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
||||
setUIMode( ui, options );
|
||||
break;
|
||||
case Type_Light:
|
||||
options.setNaviNight( false );
|
||||
@@ -432,6 +418,33 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
}
|
||||
|
||||
private void setUIMode( EnumMapUI ui, AMapNaviViewOptions options ) {
|
||||
this.mCurrentUIMode = ui;
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
case CarUp_3D:
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
// TODO: 2020-03-16 车头朝上,需要固定车标
|
||||
break;
|
||||
case NorthUP_2D:
|
||||
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
||||
// TODO: 2020-03-16 北朝上,需要动态改变车头车标
|
||||
break;
|
||||
}
|
||||
if ( options == null ) {
|
||||
return;
|
||||
}
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
case NorthUP_2D:
|
||||
options.setTilt( 0 );
|
||||
break;
|
||||
case CarUp_3D:
|
||||
options.setTilt( 60 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkAMapView() {
|
||||
if ( mMapView == null ) {
|
||||
@@ -466,6 +479,20 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
}
|
||||
|
||||
private View mCursorView;
|
||||
|
||||
@Override
|
||||
public void showMyLocation( float degree ) {
|
||||
if ( checkAMapView() ) {
|
||||
mCursorView = View.inflate( getContext(), R.layout.map_amap_cursor, null );
|
||||
mCursorView.setRotation( degree );
|
||||
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
||||
style.showMyLocation( true );
|
||||
style.myLocationIcon( BitmapDescriptorFactory.fromView( mCursorView ) );
|
||||
mMapView.getMap().setMyLocationStyle( style );
|
||||
}
|
||||
}
|
||||
|
||||
public void initMyLocation() {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMap().setMyLocationEnabled( true );
|
||||
@@ -709,4 +736,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
public void onMyLocationChange( Location location ) {
|
||||
NaviClient.getInstance( getContext() ).syncCarLocation( location );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMapUI getCurrentUiMode() {
|
||||
return mCurrentUIMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.impl.amap.uicontroller;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -91,6 +92,13 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMyLocation( float degree ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.showMyLocation( degree );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if (mClient != null) {
|
||||
@@ -217,4 +225,12 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMapUI getCurrentUiMode() {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getCurrentUiMode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
12
libraries/map-amap/src/main/res/layout/map_amap_cursor.xml
Normal file
12
libraries/map-amap/src/main/res/layout/map_amap_cursor.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/map_amap_id_cursor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_1" />
|
||||
</LinearLayout>
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.uicontroller;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -20,38 +21,43 @@ public interface IMogoMapUIController {
|
||||
/**
|
||||
* 实时路况
|
||||
*/
|
||||
void setTrafficEnabled(boolean visible);
|
||||
void setTrafficEnabled( boolean visible );
|
||||
|
||||
/**
|
||||
* 地图缩放
|
||||
*
|
||||
* @param zoomIn true - 方法 false - 缩小
|
||||
*/
|
||||
void changeZoom(boolean zoomIn);
|
||||
void changeZoom( boolean zoomIn );
|
||||
|
||||
/**
|
||||
* 修改缩放级别
|
||||
*/
|
||||
void changeZoom(float zoom);
|
||||
void changeZoom( float zoom );
|
||||
|
||||
/**
|
||||
* 切换2D/3D模式
|
||||
*
|
||||
* @param mode true - 3D模式 false - 2D模式
|
||||
*/
|
||||
void changeMapMode(EnumMapUI mode);
|
||||
void changeMapMode( EnumMapUI mode );
|
||||
|
||||
/**
|
||||
* 将地图移动至当前位置
|
||||
*/
|
||||
void moveToCenter(MogoLatLng latLng);
|
||||
void moveToCenter( MogoLatLng latLng );
|
||||
|
||||
/**
|
||||
* 显示我的位置
|
||||
*
|
||||
* @param visible true - 显示 false - 不显示
|
||||
*/
|
||||
void showMyLocation(boolean visible);
|
||||
void showMyLocation( boolean visible );
|
||||
|
||||
/**
|
||||
* @param degree 车标方向
|
||||
*/
|
||||
void showMyLocation( float degree );
|
||||
|
||||
/**
|
||||
* 锁车
|
||||
@@ -68,7 +74,7 @@ public interface IMogoMapUIController {
|
||||
*
|
||||
* @param var1 级别 3-20
|
||||
*/
|
||||
void setLockZoom(int var1);
|
||||
void setLockZoom( int var1 );
|
||||
|
||||
/**
|
||||
* 预览全程
|
||||
@@ -108,33 +114,33 @@ public interface IMogoMapUIController {
|
||||
* @param mapCenterX x 点位置x值与地图宽度的比例
|
||||
* @param mapCenterY y 点位置x值与地图高度的比例
|
||||
*/
|
||||
void setPointToCenter(double mapCenterX, double mapCenterY);
|
||||
void setPointToCenter( double mapCenterX, double mapCenterY );
|
||||
|
||||
/**
|
||||
* 获取经纬度对应的屏幕的位置
|
||||
*/
|
||||
Point getLocationPointInScreen(MogoLatLng latLng);
|
||||
Point getLocationPointInScreen( MogoLatLng latLng );
|
||||
|
||||
/**
|
||||
* 获取像素点对应的经纬度
|
||||
*/
|
||||
MogoLatLng getLocationMogoLatLngInScreen(Point point);
|
||||
MogoLatLng getLocationMogoLatLngInScreen( Point point );
|
||||
|
||||
/**
|
||||
* marker 跳跃动画
|
||||
*
|
||||
* @param marker 跳跃的 marker
|
||||
* @param high 跳跃的高度
|
||||
* @param marker 跳跃的 marker
|
||||
* @param high 跳跃的高度
|
||||
* @param interpolator 插值器
|
||||
* @param duration 动画时间
|
||||
* @param duration 动画时间
|
||||
*/
|
||||
void startJumpAnimation(IMogoMarker marker, float high, Interpolator interpolator,
|
||||
long duration);
|
||||
void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator,
|
||||
long duration );
|
||||
|
||||
/**
|
||||
* 设置刷新帧率
|
||||
*/
|
||||
void setRenderFps(int fps);
|
||||
void setRenderFps( int fps );
|
||||
|
||||
/**
|
||||
* @param tag 调用业务
|
||||
@@ -152,9 +158,17 @@ public interface IMogoMapUIController {
|
||||
|
||||
/**
|
||||
* 计算两点之间的距离
|
||||
*
|
||||
* @param p1
|
||||
* @param p2
|
||||
* @return
|
||||
*/
|
||||
float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception;
|
||||
float calculateLineDistance( MogoLatLng p1, MogoLatLng p2 ) throws Exception;
|
||||
|
||||
/**
|
||||
* 当前的视图模式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
EnumMapUI getCurrentUiMode();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.map.impl.amap.uicontroller.AMapUIController;
|
||||
@@ -85,6 +86,13 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMyLocation( float degree ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.showMyLocation( degree );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if (mDelegate != null) {
|
||||
@@ -210,4 +218,12 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMapUI getCurrentUiMode() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getCurrentUiMode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.back;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-16
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_LAUNCHER_API )
|
||||
public class MogoLauncher implements IMogoLauncher {
|
||||
|
||||
@Override
|
||||
public void backToLauncher( Context context ) {
|
||||
BackToMainHomeManager.backToLauncher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -8,8 +9,10 @@ import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.os.Trace;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,6 +26,7 @@ import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
@@ -31,6 +35,7 @@ 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.carinfo.CarStateInfo;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
@@ -40,9 +45,12 @@ import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
@@ -50,7 +58,9 @@ import com.mogo.service.module.MogoAction;
|
||||
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 com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -133,6 +143,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
private IMogoActionManager mActionManager;
|
||||
private IMogoADASController mADASController;
|
||||
private IMogoLauncher mLauncher;
|
||||
private IMogoFragmentManager mFragmentManager;
|
||||
private IMogoNavi mNavi;
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
@@ -258,6 +272,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
IMogoServiceApis apis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation();
|
||||
mMogoMapService = apis.getMapServiceApi();
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
mNavi = mMogoMapService.getNavi( context );
|
||||
mStatusManager = apis.getStatusManagerApi();
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, this );
|
||||
@@ -285,7 +300,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_OPERATION, this );
|
||||
|
||||
mADASController = apis.getAdasControllerApi();
|
||||
mLauncher = apis.getLauncherApi();
|
||||
mFragmentManager = apis.getFragmentManagerApi();
|
||||
mCardManager = apis.getCardManagerApi();
|
||||
initWorkThread();
|
||||
}
|
||||
|
||||
@@ -341,6 +362,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( Intent.ACTION_POWER_DISCONNECTED );
|
||||
// 小智语音
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_UI );
|
||||
filter.addAction( MogoReceiver.ACTION_ADAS_STATUS );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
@@ -642,7 +664,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
stopAutoRefreshStrategy();
|
||||
mRefreshRemainingTime = time;
|
||||
long delay = ServiceConst.DECREASE_INTERVAL;
|
||||
if( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ){
|
||||
if ( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ) {
|
||||
delay = mRefreshRemainingTime;
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay );
|
||||
@@ -733,11 +755,33 @@ public class MogoServices implements IMogoMapListener,
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_SHARE_MUSIC, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_SHARE_MUSIC );
|
||||
} else if ( TextUtils.equals( "探路", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_ROAD_CONDITION, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
} else if ( TextUtils.equals( "在线车辆", card ) ) {
|
||||
mCardManager.switch2( ServiceConst.CARD_TYPE_USER_DATA, true );
|
||||
switchCard2( ServiceConst.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if ( MogoReceiver.ACTION_ADAS_STATUS.equals( command ) ) {
|
||||
String msg = intent.getStringExtra( "adasMsg" );
|
||||
if ( TextUtils.isEmpty( msg ) ) {
|
||||
return;
|
||||
}
|
||||
CarStateInfo stateInfo = GsonUtil.objectFromJson( msg, CarStateInfo.class );
|
||||
if ( stateInfo != null ) {
|
||||
changeCarHeadstockDirection( stateInfo.getValues().getHeading() );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_OPERATION.equals( command ) ) {
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( TextUtils.equals( app, "车聊聊" ) ) {
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_CARS_CHATTING );
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
@@ -745,6 +789,63 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换卡片
|
||||
*
|
||||
* @param card
|
||||
*/
|
||||
private void switchCard2( String card ) {
|
||||
if ( isBackground( mContext ) ) {
|
||||
mLauncher.backToLauncher( mContext );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
mADASController.closeADAS();
|
||||
}
|
||||
mCardManager.switch2( card, true );
|
||||
}, 2000L );
|
||||
} else {
|
||||
mFragmentManager.clearAll();
|
||||
if ( mStatusManager.isADASShow() ) {
|
||||
mADASController.closeADAS();
|
||||
}
|
||||
mCardManager.switch2( card, true );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBackground( Context context ) {
|
||||
ActivityManager activityManager = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningAppProcessInfo > appProcesses = activityManager.getRunningAppProcesses();
|
||||
for ( ActivityManager.RunningAppProcessInfo appProcess : appProcesses ) {
|
||||
if ( appProcess.processName.equals( context.getPackageName() ) ) {
|
||||
if ( appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void changeCarHeadstockDirection( double degree ) {
|
||||
if ( mNavi.isNaviing() ) {
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
if ( mUiController.getCurrentUiMode() != EnumMapUI.NorthUP_2D ) {
|
||||
return;
|
||||
}
|
||||
mUiController.showMyLocation( ( ( float ) degree ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册桌面免唤醒指令
|
||||
*/
|
||||
private void registerInternalUnWakeupWords() {
|
||||
if ( mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
@@ -754,6 +855,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, ServiceConst.CMD_UN_WAKE_NEXT_UN_WAKE_WORDS, this );
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销桌面免唤醒指令
|
||||
*/
|
||||
private void unregisterInternalUnWakeupWords() {
|
||||
if ( !mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
|
||||
@@ -132,5 +132,10 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String COMMAND_SWITCH_CARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
/**
|
||||
* 打开/关闭车聊聊
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.mogo.module.service.carinfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 车辆状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class CarStateInfo implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* action : “state”
|
||||
* values : {"lon":116.8,"lat":39.4,"alt":22.3,"heading":87.5,"acceleration":0.5,"yaw_rate":0.3}
|
||||
*/
|
||||
|
||||
private String action;
|
||||
private ValuesBean values;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ValuesBean getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(ValuesBean values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* lon : 116.8
|
||||
* lat : 39.4
|
||||
* alt : 22.3
|
||||
* heading : 87.5
|
||||
* acceleration : 0.5
|
||||
* yaw_rate : 0.3
|
||||
*/
|
||||
|
||||
private double lon;
|
||||
private double lat;
|
||||
private double alt;
|
||||
private double heading;
|
||||
private double acceleration;
|
||||
private double yaw_rate;
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(double alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public double getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public void setAcceleration(double acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public double getYaw_rate() {
|
||||
return yaw_rate;
|
||||
}
|
||||
|
||||
public void setYaw_rate(double yaw_rate) {
|
||||
this.yaw_rate = yaw_rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"lon=" + lon +
|
||||
", lat=" + lat +
|
||||
", alt=" + alt +
|
||||
", heading=" + heading +
|
||||
", acceleration=" + acceleration +
|
||||
", yaw_rate=" + yaw_rate +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CarStateInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.module.service.datamanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.datamanager.IMogoDataChanged2Listener;
|
||||
import com.mogo.service.datamanager.IMogoDataChangedListener;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -20,7 +20,7 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoDataHandler {
|
||||
public class MogoDataHandler implements IMogoDataManager {
|
||||
|
||||
private static final String TAG = "MogoDataHandler";
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MogoDataHandler {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( tag ) || mListeners.get( tag ) == null ) {
|
||||
mListeners.put( tag, new ArrayList< IMogoDataChangedListener >() );
|
||||
mListeners.put( tag, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( tag ).add( listener );
|
||||
}
|
||||
@@ -57,6 +57,47 @@ public class MogoDataHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@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 ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@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 ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
public void invoke( String tag, Object data ) {
|
||||
if ( tag == null || mListeners.get( tag ) == null ) {
|
||||
return;
|
||||
@@ -69,8 +110,8 @@ public class MogoDataHandler {
|
||||
listener.onDataSetChanged( data );
|
||||
}
|
||||
}
|
||||
} catch( Exception e ){
|
||||
Logger.e(TAG, e, "error.");
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,17 @@ public class MogoDataManager implements IMogoDataManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
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 init( Context context ) {
|
||||
MogoDataHandler.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
public static final String VALUE_DISMISS = "dismiss";
|
||||
public static final String VALUE_SHOW = "show";
|
||||
|
||||
/**
|
||||
* 从 adas 同步过来的信息
|
||||
*/
|
||||
public static final String ACTION_ADAS_STATUS = "com.zhidao.autopilot.adas.msg";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver( Context context ) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -158,7 +159,15 @@ public interface IMogoServiceApis extends IProvider {
|
||||
|
||||
/**
|
||||
* 地址操作
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoAddressManager getAddressManagerApi();
|
||||
|
||||
/**
|
||||
* 桌面控制接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoLauncher getLauncherApi();
|
||||
}
|
||||
|
||||
@@ -153,5 +153,11 @@ public class MogoServicePaths {
|
||||
* 刷新策略控制
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_REFRESH_STRATEGY_API = "refreshstrategy/api";
|
||||
public static final String PATH_REFRESH_STRATEGY_API = "/refreshstrategy/api";
|
||||
|
||||
/**
|
||||
* 刷新策略控制
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_LAUNCHER_API = "/launcher/api";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.service.datamanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-11
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface IMogoDataChanged2Listener extends IMogoDataChangedListener {
|
||||
|
||||
/**
|
||||
* 添加数据到指定类型
|
||||
*
|
||||
* @param module
|
||||
* @param object
|
||||
*/
|
||||
void onDataAdded( String module, Object object );
|
||||
|
||||
/**
|
||||
* 从数据从指定类型中移除
|
||||
*
|
||||
* @param module
|
||||
* @param object
|
||||
*/
|
||||
void onDataRemoved( String module, Object object );
|
||||
}
|
||||
@@ -13,15 +13,31 @@ public interface IMogoDataManager extends IProvider {
|
||||
/**
|
||||
* 注册大而全数据变化监听
|
||||
*
|
||||
* @param tag 监听模块
|
||||
* @param module 监听模块
|
||||
* @param listener
|
||||
*/
|
||||
void registerDataListener( String tag, IMogoDataChangedListener listener );
|
||||
void registerDataListener( String module, IMogoDataChangedListener listener );
|
||||
|
||||
/**
|
||||
* 注销大而全数据变换监听
|
||||
*
|
||||
* @param tag
|
||||
* @param module
|
||||
*/
|
||||
void unregisterListener( String tag , IMogoDataChangedListener listener);
|
||||
void unregisterListener( String module, IMogoDataChangedListener listener );
|
||||
|
||||
/**
|
||||
* 发送数据到指定模块
|
||||
*
|
||||
* @param module 模块
|
||||
* @param object 数据
|
||||
*/
|
||||
void addData2( String module, Object object );
|
||||
|
||||
/**
|
||||
* 自定模块删除数据
|
||||
*
|
||||
* @param module 模块
|
||||
* @param object 数据
|
||||
*/
|
||||
void removeDataFrom( String module, Object object );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.service.launcher;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-16
|
||||
* <p>
|
||||
* 桌面控制器
|
||||
*/
|
||||
public interface IMogoLauncher extends IProvider {
|
||||
|
||||
/**
|
||||
* 返回桌面主页
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
void backToLauncher( Context context );
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.mogo.service.impl.imageloader.glide.GlideImageLoader;
|
||||
import com.mogo.service.impl.intent.IntentManager;
|
||||
import com.mogo.service.impl.singleton.SingletonsHolder;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -147,6 +148,11 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
return getApiInstance( IMogoAddressManager.class, MogoServicePaths.PATH_ADDRESS_MANAGER );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLauncher getLauncherApi() {
|
||||
return getApiInstance( IMogoLauncher.class, MogoServicePaths.PATH_LAUNCHER_API );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
|
||||
T inst = SingletonsHolder.get( clazz );
|
||||
if ( inst == null ) {
|
||||
|
||||
Reference in New Issue
Block a user