Merge remote-tracking branch 'origin/feature/v1.0.4' into feature/v1.0.4
# Conflicts: # modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
This commit is contained in:
@@ -82,6 +82,10 @@ public class MarkerServiceHandler {
|
||||
mMapMarkerManager.init( context );
|
||||
}
|
||||
|
||||
public static IMogoServiceApis getApis(){
|
||||
return mApis;
|
||||
}
|
||||
|
||||
public static IMogoMapService getMapService() {
|
||||
return mMapService;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.location.LocationManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Trace;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@@ -37,6 +36,7 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.service.carinfo.CarStateInfo;
|
||||
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;
|
||||
@@ -44,6 +44,7 @@ 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.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
@@ -58,13 +59,11 @@ 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.AppUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
@@ -207,8 +206,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
notifyRefreshData( mLastAutoRefreshLocation,
|
||||
ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
}
|
||||
};
|
||||
private Context mContext;
|
||||
@@ -508,6 +506,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.d( TAG, "mLastZoomLevel = %s, zoom = %s", mLastZoomLevel, zoom );
|
||||
|
||||
// 手动刷新触发
|
||||
if ( mLastZoomLevel - zoom > mCustomRefreshStrategy.getZoomOutLevel() ) {
|
||||
// 缩放级别缩小
|
||||
@@ -522,6 +522,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
msg.what = ServiceConst.MSG_MAP_CHANGED;
|
||||
msg.obj = new RefreshObject( mCustomRefreshCallback, getQueryRadius(), latLng, 0 );
|
||||
mThreadHandler.sendMessage( msg );
|
||||
Logger.d( TAG, "平移触发" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +540,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private boolean invokeRefreshWhenTranslationByUser( MogoLatLng latLng ) {
|
||||
try {
|
||||
Trace.beginSection( "timer.invokeRefreshWhenTranslationByUser" );
|
||||
float factor = 0.0f;
|
||||
if ( mIsVertical ) {
|
||||
factor = getMapCameraFactWidth();
|
||||
@@ -550,7 +550,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
return false;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance( latLng, mLastCustomRefreshCenterLocation );
|
||||
Trace.endSection();
|
||||
Logger.d( TAG, "move distance = %s, factor = %s", distance, factor );
|
||||
return distance > factor;
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "warming. " );
|
||||
@@ -669,17 +669,18 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
break;
|
||||
case SEEK_HELPING:
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( mUiController, isTrue );
|
||||
notifySeekHelpingStatusChanged( isTrue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifySeekHelpingStatusChanged( boolean open ) {
|
||||
private void notifySeekHelpingStatusChanged( boolean seekHelpingStatus ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas.app" );
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put( "object", "辅助驾驶" );
|
||||
data.put( "action", open ? "2" : "1" );
|
||||
data.put( "action", seekHelpingStatus ? "2" : "1" );
|
||||
data.put( "des", "自身故障报警" );
|
||||
data.put( "v2x_warning_type", "20007" );// 后台返回
|
||||
intent.putExtra( "data", data.toString() );
|
||||
@@ -787,33 +788,14 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_NEXT.equals( command ) ) {
|
||||
if ( mStatusManager.isMainPageOnResume() ) {
|
||||
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(),
|
||||
MogoAction.Next );
|
||||
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Next );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) {
|
||||
if ( mStatusManager.isMainPageOnResume() ) {
|
||||
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(),
|
||||
MogoAction.Prev );
|
||||
mActionManager.invoke( MapMarkerManager.getInstance().getCurrentModuleName(), MogoAction.Prev );
|
||||
}
|
||||
} else if ( ServiceConst.COMMAND_SWITCH_CARD.equals( command ) ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体卡片", card )
|
||||
|| TextUtils.equals( "媒体中心卡片", card )
|
||||
|| TextUtils.equals( "音乐卡片", card ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_SHARE_MUSIC );
|
||||
} else if ( TextUtils.equals( "探路卡片", card ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
} else if ( TextUtils.equals( "在线车辆卡片", card ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_USER_DATA );
|
||||
} else if ( TextUtils.equals( "新鲜事卡片", card ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_NOVELTY );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
|
||||
} else if ( MogoReceiver.ACTION_ADAS_STATUS.equals( command ) ) {
|
||||
String msg = intent.getStringExtra( "adasMsg" );
|
||||
if ( TextUtils.isEmpty( msg ) ) {
|
||||
@@ -825,62 +807,14 @@ public class MogoServices implements IMogoMapListener,
|
||||
// changeMyLocation( stateInfo.getValues() );
|
||||
}
|
||||
} 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 );
|
||||
}
|
||||
} else {
|
||||
if ( TextUtils.equals( app, "探路" ) ) {
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
switchCard2( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
|
||||
} else if ( MogoReceiver.ACTION_VOICE_READY.equals( command ) ) {
|
||||
AIAssist.getInstance( mContext ).flush();
|
||||
mStatusManager.setAIAssistReady( TAG, true );
|
||||
} else if ( ServiceConst.COMMAND_MY_LOCATION.equals( command ) ) {
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isMainPageOnResume() ) {
|
||||
mUiController.recoverLockMode();
|
||||
}
|
||||
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
|
||||
} else if ( MogoReceiver.ACTION_MOCK.equals( command ) ) {
|
||||
final int oper = intent.getIntExtra( "oper", -1 );
|
||||
switch ( oper ) {
|
||||
case 1:
|
||||
mUiController.showMyLocation( true );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换卡片
|
||||
*/
|
||||
private void switchCard2( String card ) {
|
||||
if ( AppUtils.isApplicationBroughtToBackground( 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 );
|
||||
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,11 +828,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
if ( mStatusManager.isSeekHelping() ) {
|
||||
return;
|
||||
}
|
||||
if ( mUiController.getCurrentUiMode() != EnumMapUI.NorthUP_2D ) {
|
||||
return;
|
||||
}
|
||||
UiThreadHandler.post( () -> {
|
||||
|
||||
mUiController.showMyLocation( inflateCursorView( degree ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ServiceConst {
|
||||
public static final int DEFAULT_LOCK_CAR_ZOOM_LEVEL = 16;
|
||||
|
||||
/**
|
||||
* 自动酸辛默认半径
|
||||
* 自动刷新默认半径
|
||||
*/
|
||||
public static final int DEFAULT_AUTO_REFRESH_DATA_RADIUS = 2_000;
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppOperationIntentHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
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 ) ) {
|
||||
SwitchCardIntentHandler.switchCard2( context, ServiceConst.CARD_TYPE_CARS_CHATTING );
|
||||
}
|
||||
} else {
|
||||
if ( TextUtils.equals( app, "探路" ) ) {
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
SwitchCardIntentHandler.switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EmptyIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "EmptyIntentHandler";
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
Logger.w( TAG, "空实现." );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface IntentHandler {
|
||||
|
||||
void handle( Context context, Intent intent );
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class IntentHandlerFactory {
|
||||
|
||||
private IntentHandlerFactory() {
|
||||
// private constructor
|
||||
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_SWITCH_CARD, new SwitchCardIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final IntentHandlerFactory INSTANCE = new IntentHandlerFactory();
|
||||
}
|
||||
|
||||
public static IntentHandlerFactory getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Map< String, IntentHandler > mHandlers = new HashMap<>();
|
||||
|
||||
private IntentHandler DEFAULT = new EmptyIntentHandler();
|
||||
|
||||
private IntentHandler getIntentHandler( String intent ) {
|
||||
if ( mHandlers.containsKey( intent ) && mHandlers.get( intent ) != null ) {
|
||||
return mHandlers.get( intent );
|
||||
}
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
public void handle( Context context, String intent, Intent obj ) {
|
||||
IntentHandler handler = getIntentHandler( intent );
|
||||
if ( handler != null ) {
|
||||
handler.handle( context, obj );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MockIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "MockIntentHandler";
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
if ( !DebugConfig.isDebug() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int oper = intent.getIntExtra( "oper", -1 );
|
||||
switch ( oper ) {
|
||||
case 1:
|
||||
MarkerServiceHandler.getMapUIController().showMyLocation( true );
|
||||
break;
|
||||
case 2:
|
||||
boolean status = intent.getBooleanExtra( "status", false );
|
||||
MarkerServiceHandler.getMogoStatusManager().setSeekHelping( TAG, status );
|
||||
break;
|
||||
case 3:
|
||||
String msg = intent.getStringExtra( "msg" );
|
||||
if ( !TextUtils.isEmpty( msg ) ) {
|
||||
TipToast.shortTip( msg );
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
TextView button1 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 );
|
||||
if ( button1 != null ) {
|
||||
button1.setVisibility( View.VISIBLE );
|
||||
button1.setBackgroundColor( Color.RED );
|
||||
button1.setOnClickListener( view -> {
|
||||
TipToast.shortTip( "测试" );
|
||||
} );
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 );
|
||||
if ( button2 != null ) {
|
||||
button2.setOnClickListener( null );
|
||||
button2.setVisibility( View.GONE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 语音指令:定位我的位置等处理
|
||||
*/
|
||||
public class MyLocationHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getMapUIController().recoverLockMode();
|
||||
} else {
|
||||
MarkerServiceHandler.getLauncher().backToLauncher( context );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MarkerServiceHandler.getMapUIController().recoverLockMode();
|
||||
}, 2_000L );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class SwitchCardIntentHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
String card = jsonObject.getString( "card" );
|
||||
if ( TextUtils.equals( "多媒体卡片", card )
|
||||
|| TextUtils.equals( "媒体中心卡片", card )
|
||||
|| TextUtils.equals( "音乐卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_SHARE_MUSIC );
|
||||
} else if ( TextUtils.equals( "探路卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
} else if ( TextUtils.equals( "在线车辆卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_USER_DATA );
|
||||
} else if ( TextUtils.equals( "新鲜事卡片", card ) ) {
|
||||
switchCard2( context, ServiceConst.CARD_TYPE_NOVELTY );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换卡片
|
||||
*/
|
||||
public static void switchCard2( Context context, String card ) {
|
||||
if ( AppUtils.isApplicationBroughtToBackground( context ) ) {
|
||||
MarkerServiceHandler.getLauncher().backToLauncher( context );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
|
||||
MarkerServiceHandler.getADASController().closeADAS();
|
||||
}
|
||||
MarkerServiceHandler.getMogoCardManager().switch2( card, true );
|
||||
}, 2000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getFragmentManager().clearAll();
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isADASShow() ) {
|
||||
MarkerServiceHandler.getADASController().closeADAS();
|
||||
}
|
||||
MarkerServiceHandler.getMogoCardManager().switch2( card, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
package com.mogo.module.service.strategy;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-16
|
||||
* <p>
|
||||
* 上报故障求助之后自车的图标显示策略
|
||||
*/
|
||||
public class CarIconDisplayStrategy {
|
||||
|
||||
public static final int MSG_SEEK_HELPING_ANIM = 2000;
|
||||
|
||||
// F 系列才有这个帧动画
|
||||
public static final int[] sFrame = {
|
||||
R.drawable.module_service_ic_seek_helping_00000,
|
||||
R.drawable.module_service_ic_seek_helping_00001,
|
||||
R.drawable.module_service_ic_seek_helping_00002,
|
||||
R.drawable.module_service_ic_seek_helping_00003,
|
||||
R.drawable.module_service_ic_seek_helping_00004,
|
||||
R.drawable.module_service_ic_seek_helping_00005,
|
||||
R.drawable.module_service_ic_seek_helping_00006,
|
||||
R.drawable.module_service_ic_seek_helping_00007,
|
||||
R.drawable.module_service_ic_seek_helping_00008,
|
||||
R.drawable.module_service_ic_seek_helping_00009,
|
||||
R.drawable.module_service_ic_seek_helping_00010,
|
||||
R.drawable.module_service_ic_seek_helping_00011,
|
||||
R.drawable.module_service_ic_seek_helping_00012,
|
||||
R.drawable.module_service_ic_seek_helping_00013,
|
||||
R.drawable.module_service_ic_seek_helping_00014,
|
||||
R.drawable.module_service_ic_seek_helping_00015,
|
||||
R.drawable.module_service_ic_seek_helping_00016,
|
||||
R.drawable.module_service_ic_seek_helping_00017,
|
||||
R.drawable.module_service_ic_seek_helping_00018,
|
||||
R.drawable.module_service_ic_seek_helping_00019,
|
||||
R.drawable.module_service_ic_seek_helping_00020,
|
||||
R.drawable.module_service_ic_seek_helping_00021,
|
||||
R.drawable.module_service_ic_seek_helping_00022,
|
||||
R.drawable.module_service_ic_seek_helping_00023,
|
||||
R.drawable.module_service_ic_seek_helping_00024,
|
||||
R.drawable.module_service_ic_seek_helping_00025,
|
||||
R.drawable.module_service_ic_seek_helping_00026,
|
||||
R.drawable.module_service_ic_seek_helping_00027,
|
||||
R.drawable.module_service_ic_seek_helping_00028,
|
||||
R.drawable.module_service_ic_seek_helping_00029,
|
||||
R.drawable.module_service_ic_seek_helping_00030,
|
||||
R.drawable.module_service_ic_seek_helping_00031,
|
||||
R.drawable.module_service_ic_seek_helping_00032,
|
||||
R.drawable.module_service_ic_seek_helping_00033,
|
||||
R.drawable.module_service_ic_seek_helping_00034,
|
||||
R.drawable.module_service_ic_seek_helping_00035,
|
||||
R.drawable.module_service_ic_seek_helping_00036,
|
||||
R.drawable.module_service_ic_seek_helping_00037,
|
||||
R.drawable.module_service_ic_seek_helping_00038,
|
||||
R.drawable.module_service_ic_seek_helping_00039,
|
||||
R.drawable.module_service_ic_seek_helping_00040,
|
||||
R.drawable.module_service_ic_seek_helping_00041,
|
||||
R.drawable.module_service_ic_seek_helping_00042,
|
||||
R.drawable.module_service_ic_seek_helping_00043,
|
||||
R.drawable.module_service_ic_seek_helping_00044,
|
||||
R.drawable.module_service_ic_seek_helping_00045,
|
||||
R.drawable.module_service_ic_seek_helping_00046,
|
||||
R.drawable.module_service_ic_seek_helping_00047,
|
||||
R.drawable.module_service_ic_seek_helping_00048,
|
||||
R.drawable.module_service_ic_seek_helping_00049,
|
||||
R.drawable.module_service_ic_seek_helping_00050,
|
||||
R.drawable.module_service_ic_seek_helping_00051,
|
||||
R.drawable.module_service_ic_seek_helping_00052,
|
||||
R.drawable.module_service_ic_seek_helping_00053,
|
||||
R.drawable.module_service_ic_seek_helping_00054,
|
||||
R.drawable.module_service_ic_seek_helping_00055,
|
||||
R.drawable.module_service_ic_seek_helping_00056,
|
||||
R.drawable.module_service_ic_seek_helping_00057,
|
||||
R.drawable.module_service_ic_seek_helping_00058,
|
||||
R.drawable.module_service_ic_seek_helping_00059,
|
||||
R.drawable.module_service_ic_seek_helping_00060,
|
||||
R.drawable.module_service_ic_seek_helping_00061,
|
||||
R.drawable.module_service_ic_seek_helping_00062,
|
||||
R.drawable.module_service_ic_seek_helping_00063,
|
||||
R.drawable.module_service_ic_seek_helping_00064
|
||||
};
|
||||
|
||||
private static volatile CarIconDisplayStrategy sInstance;
|
||||
private IMogoMapUIController mController;
|
||||
|
||||
private CarIconDisplayStrategy() {
|
||||
mOption = new CarCursorOption.Builder().carCursorRes( R.drawable.module_service_ic_seek_helping ).build();
|
||||
}
|
||||
|
||||
public static CarIconDisplayStrategy getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( CarIconDisplayStrategy.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new CarIconDisplayStrategy();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Handler mSeekHelpingHandler;
|
||||
private int mCounter = 0;
|
||||
private boolean mStopStatus = true;
|
||||
private CarCursorOption mOption;
|
||||
|
||||
public void changeCarIconStatus( IMogoMapUIController controller, boolean seekHelpingStatus ) {
|
||||
mController = controller;
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
if ( seekHelpingStatus ) {
|
||||
playSeekHelpingAnim();
|
||||
} else {
|
||||
stopSeekHelpingAnim();
|
||||
}
|
||||
} else {
|
||||
if ( seekHelpingStatus ) {
|
||||
controller.setCarCursorOption( mOption );
|
||||
} else {
|
||||
controller.setCarCursorOption( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playSeekHelpingAnim() {
|
||||
initHandler();
|
||||
mStopStatus = false;
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SEEK_HELPING_ANIM;
|
||||
msg.arg1 = mCounter++;
|
||||
mSeekHelpingHandler.sendMessageDelayed( msg, 100 );
|
||||
}
|
||||
|
||||
private void initHandler() {
|
||||
if ( mSeekHelpingHandler != null ) {
|
||||
return;
|
||||
}
|
||||
mSeekHelpingHandler = new Handler( WorkThreadHandler.getInstance().getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( mStopStatus ) {
|
||||
mSeekHelpingHandler.removeMessages( MSG_SEEK_HELPING_ANIM );
|
||||
mCounter = 0;
|
||||
mController.setCarCursorOption( null );
|
||||
return;
|
||||
}
|
||||
switch ( msg.what ) {
|
||||
case MSG_SEEK_HELPING_ANIM:
|
||||
mOption.setCarCursorRes( sFrame[msg.arg1 % sFrame.length] );
|
||||
mController.setCarCursorOption( mOption );
|
||||
playSeekHelpingAnim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void stopSeekHelpingAnim() {
|
||||
mStopStatus = true;
|
||||
if ( mSeekHelpingHandler == null ) {
|
||||
return;
|
||||
}
|
||||
mCounter = 0;
|
||||
mSeekHelpingHandler.removeMessages( MSG_SEEK_HELPING_ANIM );
|
||||
mController.setCarCursorOption( null );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user