This commit is contained in:
wangcongtao
2020-04-17 10:22:58 +08:00
parent 9f1e50a3bc
commit c0bb5e44b2
23 changed files with 509 additions and 128 deletions

View File

@@ -32,8 +32,8 @@ MOGO_UTILS_VERSION=1.0.3.3
MAP_AMAP_VERSION=1.0.3.4
MOGO_MAP_VERSION=1.0.3.4
MOGO_MAP_API_VERSION=1.0.3.4
MOGO_SERVICE_VERSION=1.0.3.4
MOGO_SERVICE_API_VERSION=1.0.3.4
MOGO_SERVICE_VERSION=1.0.3.5
MOGO_SERVICE_API_VERSION=1.0.3.5
MOGO_CONNECTION_VERSION=1.0.3.4
MOGO_MODULE_APPS_VERSION=1.0.3.4
MOGO_MODULE_NAVI_VERSION=1.0.3.4
@@ -42,7 +42,7 @@ MOGO_MODULE_COMMON_VERSION=1.0.3.4
MOGO_MODULE_MAIN_VERSION=1.0.3.4
MOGO_MODULE_MAP_VERSION=1.0.3.4
MOGO_MODULE_SERVICE_VERSION=1.0.3.4
MOGO_MODULE_EXTENSIONS_VERSION=1.0.3.4
MOGO_MODULE_EXTENSIONS_VERSION=1.0.3.5
MOGO_MODULE_SEARCH_VERSION=1.0.3.4
MOGO_MODULE_BACK_VERSION=1.0.3.4
MOGO_MODULE_GPS_SIMULATOR_VERSION=1.0.3.4

View File

@@ -1,5 +1,5 @@
#!/bin/bash
./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives
./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives
./gradlew :libraries:mogo-map:clean :libraries:mogo-map:uploadArchives
./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives
./gradlew :services:mogo-service:clean :services:mogo-service:uploadArchives
./gradlew :modules:mogo-module-extensions:clean :modules:mogo-module-extensions:uploadArchives

View File

@@ -39,6 +39,7 @@ import com.mogo.module.share.ShareControl;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.map.IMogoMapService;
@@ -221,6 +222,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
}
}
} );
MogoEntranceButtons.save( ButtonIndex.BUTTON1, findViewById( R.id.module_entrance_id_button1 ) );
MogoEntranceButtons.save( ButtonIndex.BUTTON2, findViewById( R.id.module_entrance_id_button2 ) );
}

View File

@@ -0,0 +1,29 @@
package com.mogo.module.extensions.entrance;
import android.content.Context;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.entrance.IMogoEntranceButtonController;
/**
* @author congtaowang
* @since 2020-04-16
* <p>
* 描述
*/
@Route( path = MogoServicePaths.PATH_ENTRANCE_BUTTON_API )
public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonController {
@Override
public TextView getButton( ButtonIndex index ) {
return MogoEntranceButtons.getButton( index );
}
@Override
public void init( Context context ) {
}
}

View File

@@ -0,0 +1,31 @@
package com.mogo.module.extensions.entrance;
import android.widget.TextView;
import com.mogo.service.entrance.ButtonIndex;
import java.util.HashMap;
import java.util.Map;
/**
* @author congtaowang
* @since 2020-04-16
* <p>
* 描述
*/
public class MogoEntranceButtons {
private static Map< ButtonIndex, TextView > sButtons = new HashMap<>();
public static void save( ButtonIndex index, TextView btn ) {
sButtons.put( index, btn );
}
public static TextView getButton( ButtonIndex index ) {
return sButtons.get( index );
}
public static void clear() {
sButtons.clear();
}
}

View File

@@ -80,8 +80,8 @@
android:layout_marginRight="@dimen/module_ext_speed_limit_marginRight"
android:background="@drawable/module_ext_dw_speed_limit_bkg"
android:gravity="center"
android:visibility="invisible"
android:orientation="vertical"
android:visibility="invisible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
@@ -116,18 +116,18 @@
<TextView
android:id="@+id/module_ext_id_north"
android:layout_width="@dimen/dp_120"
android:text="@string/mode_north_up"
android:paddingTop="@dimen/dp_14"
android:visibility="gone"
android:textColor="@color/white"
android:textSize="@dimen/dp_28"
android:gravity="center_horizontal"
android:layout_height="@dimen/dp_120"
android:layout_marginTop="@dimen/dp_33"
android:background="@drawable/shape_react_gray_round"
android:drawableTop="@drawable/selector_icon_north_up"
app:layout_constraintTop_toBottomOf="@+id/module_entrance_id_navi_info_panel"
android:gravity="center_horizontal"
android:paddingTop="@dimen/dp_14"
android:text="@string/mode_north_up"
android:textColor="@color/white"
android:textSize="@dimen/dp_28"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/module_entrance_id_navi_info_panel"
android:layout_height="@dimen/dp_120"/>
app:layout_constraintTop_toBottomOf="@+id/module_entrance_id_navi_info_panel" />
<LinearLayout
android:id="@+id/module_entrance_id_operation_panel"
@@ -194,18 +194,52 @@
app:layout_goneMarginBottom="@dimen/module_ext_operation_panel_share_goneMarginBottom"
app:layout_goneMarginRight="@dimen/module_ext_operation_panel_share_goneMarginRight" />
<TextView
android:id="@+id/module_entrance_id_exit_navi"
android:layout_width="@dimen/module_ext_navi_exit_width"
android:layout_height="@dimen/module_ext_navi_exit_height"
android:layout_marginLeft="@dimen/module_ext_navi_exit_marginLeft"
android:layout_marginBottom="@dimen/module_ext_navi_exit_marginBottom"
android:background="@drawable/module_ext_dw_common_corner_bkg"
android:gravity="center"
android:text="退出导航"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_navi_exit_textSize"
android:visibility="gone"
<LinearLayout
android:id="@+id/module_entrance_id_buttons_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/module_ext_button_container_marginLeft"
android:layout_marginBottom="@dimen/module_ext_button_container_marginBottom"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
app:layout_constraintLeft_toLeftOf="parent">
<TextView
android:id="@+id/module_entrance_id_button1"
android:layout_width="@dimen/module_ext_navi_exit_width"
android:layout_height="@dimen/module_ext_navi_exit_height"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_navi_exit_textSize"
android:visibility="gone"
tools:background="@drawable/module_ext_dw_common_corner_bkg"
tools:text="前方\n实况"
tools:visibility="visible" />
<TextView
android:id="@+id/module_entrance_id_button2"
android:layout_width="@dimen/module_ext_navi_exit_width"
android:layout_height="@dimen/module_ext_navi_exit_height"
android:layout_marginTop="@dimen/module_entrance_id_button_marginTop"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_navi_exit_textSize"
android:visibility="gone"
tools:background="@drawable/module_ext_dw_common_corner_bkg"
tools:text="取消\n求助"
tools:visibility="visible" />
<TextView
android:id="@+id/module_entrance_id_exit_navi"
android:layout_width="@dimen/module_ext_navi_exit_width"
android:layout_height="@dimen/module_ext_navi_exit_height"
android:layout_marginTop="@dimen/module_entrance_id_button_marginTop"
android:background="@drawable/module_ext_dw_common_corner_bkg"
android:gravity="center"
android:text="退出\n导航"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_navi_exit_textSize"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -46,11 +46,14 @@
<dimen name="module_ext_operation_panel_share_goneMarginRight">20px</dimen>
<dimen name="module_ext_navi_exit_width">130px</dimen>
<dimen name="module_ext_navi_exit_height">58px</dimen>
<dimen name="module_ext_navi_exit_width">64px</dimen>
<dimen name="module_ext_navi_exit_height">64px</dimen>
<dimen name="module_ext_navi_exit_marginLeft">20px</dimen>
<dimen name="module_ext_navi_exit_marginBottom">32px</dimen>
<dimen name="module_ext_button_container_marginLeft">20px</dimen>
<dimen name="module_ext_button_container_marginBottom">30px</dimen>
<dimen name="module_ext_navi_exit_textSize">22px</dimen>
<dimen name="module_entrance_id_button_marginTop">8px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">64px</dimen>

View File

@@ -44,11 +44,14 @@
<dimen name="module_ext_operation_panel_share_goneMarginBottom">32px</dimen>
<dimen name="module_ext_operation_panel_share_goneMarginRight">32px</dimen>
<dimen name="module_ext_navi_exit_width">200px</dimen>
<dimen name="module_ext_navi_exit_height">90px</dimen>
<dimen name="module_ext_navi_exit_width">120px</dimen>
<dimen name="module_ext_navi_exit_height">120px</dimen>
<dimen name="module_ext_navi_exit_marginLeft">32px</dimen>
<dimen name="module_ext_navi_exit_marginBottom">60px</dimen>
<dimen name="module_ext_button_container_marginLeft">32px</dimen>
<dimen name="module_ext_button_container_marginBottom">60px</dimen>
<dimen name="module_ext_navi_exit_textSize">32px</dimen>
<dimen name="module_entrance_id_button_marginTop">20px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">120px</dimen>

View File

@@ -44,11 +44,14 @@
<dimen name="module_ext_operation_panel_share_goneMarginBottom">32px</dimen>
<dimen name="module_ext_operation_panel_share_goneMarginRight">32px</dimen>
<dimen name="module_ext_navi_exit_width">200px</dimen>
<dimen name="module_ext_navi_exit_height">90px</dimen>
<dimen name="module_ext_navi_exit_width">120px</dimen>
<dimen name="module_ext_navi_exit_height">120px</dimen>
<dimen name="module_ext_navi_exit_marginLeft">32px</dimen>
<dimen name="module_ext_navi_exit_marginBottom">60px</dimen>
<dimen name="module_ext_button_container_marginLeft">32px</dimen>
<dimen name="module_ext_button_container_marginBottom">60px</dimen>
<dimen name="module_ext_navi_exit_textSize">32px</dimen>
<dimen name="module_entrance_id_button_marginTop">20px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">120px</dimen>

View File

@@ -82,6 +82,10 @@ public class MarkerServiceHandler {
mMapMarkerManager.init( context );
}
public static IMogoServiceApis getApis(){
return mApis;
}
public static IMogoMapService getMapService() {
return mMapService;
}

View File

@@ -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;
@@ -30,7 +29,6 @@ import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.map.navi.MogoCongestionInfo;
import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.uicontroller.CarCursorOption;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.MogoModule;
@@ -38,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;
@@ -60,14 +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.TipToast;
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;
@@ -796,24 +792,7 @@ public class MogoServices implements IMogoMapListener,
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,82 +804,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();
} else {
mLauncher.backToLauncher( mContext );
UiThreadHandler.postDelayed( () -> {
mUiController.recoverLockMode();
}, 2_000L );
}
IntentHandlerFactory.getInstance().handle( mContext, command, intent );
} else if ( MogoReceiver.ACTION_MOCK.equals( command ) ) {
if ( !DebugConfig.isDebug() ) {
return;
}
final int oper = intent.getIntExtra( "oper", -1 );
switch ( oper ) {
case 1:
mUiController.showMyLocation( true );
break;
case 2:
boolean status = intent.getBooleanExtra( "status", false );
mStatusManager.setSeekHelping( TAG, status );
break;
case 3:
String msg = intent.getStringExtra( "msg" );
if ( !TextUtils.isEmpty( msg ) ) {
TipToast.shortTip( msg );
}
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 );
}
}

View File

@@ -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();
}
}
}

View File

@@ -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, "空实现." );
}
}

View File

@@ -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 );
}

View File

@@ -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 );
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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 );
}
}
}

View File

@@ -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 );
}
}
}

View File

@@ -8,6 +8,7 @@ import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cardmanager.IMogoCardManager;
import com.mogo.service.connection.IMogoSocketManager;
import com.mogo.service.datamanager.IMogoDataManager;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.intent.IMogoIntentManager;
@@ -170,4 +171,11 @@ public interface IMogoServiceApis extends IProvider {
* @return
*/
IMogoLauncher getLauncherApi();
/**
* 获取入口按钮控制器
*
* @return
*/
IMogoEntranceButtonController getEntranceButtonController();
}

View File

@@ -160,4 +160,10 @@ public class MogoServicePaths {
*/
@Deprecated
public static final String PATH_LAUNCHER_API = "/launcher/api";
/**
* 入口按钮
*/
@Deprecated
public static final String PATH_ENTRANCE_BUTTON_API = "/entrancebutton/api";
}

View File

@@ -0,0 +1,20 @@
package com.mogo.service.entrance;
/**
* @author congtaowang
* @since 2020-04-16
* <p>
* 入口按钮顺序:从上到下
*/
public enum ButtonIndex {
/**
* 第一个
*/
BUTTON1,
/**
* 第二个
*/
BUTTON2;
}

View File

@@ -0,0 +1,22 @@
package com.mogo.service.entrance;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* @author congtaowang
* @since 2020-04-16
* <p>
* 入口按钮
*/
public interface IMogoEntranceButtonController extends IProvider {
/**
* 获取入口按钮实例
*
* @param index
* @return
*/
TextView getButton( ButtonIndex index );
}

View File

@@ -13,6 +13,7 @@ import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cardmanager.IMogoCardManager;
import com.mogo.service.connection.IMogoSocketManager;
import com.mogo.service.datamanager.IMogoDataManager;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.impl.analytics.impl.MogoAnalyticsImpl;
@@ -153,6 +154,11 @@ public class MogoServiceApis implements IMogoServiceApis {
return getApiInstance( IMogoLauncher.class, MogoServicePaths.PATH_LAUNCHER_API );
}
@Override
public IMogoEntranceButtonController getEntranceButtonController() {
return getApiInstance( IMogoEntranceButtonController.class, MogoServicePaths.PATH_ENTRANCE_BUTTON_API );
}
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
T inst = SingletonsHolder.get( clazz );
if ( inst == null ) {