opt
This commit is contained in:
@@ -30,24 +30,24 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
super.onCreate();
|
||||
// MogoModulePaths.addModule( new MogoModule( DemoConstants.TAG, "CARD_DEMO" ) );
|
||||
// MogoModulePaths.addModule( new MogoModule( Demo2Constants.TAG, "CARD_DEMO2" ) );
|
||||
DebugConfig.setNetMode(DebugConfig.NET_MODE_QA);
|
||||
MogoModulePaths.addModule(new MogoModule(OnLineCarConstants.TAG, OnLineCarConstants.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(TanluConstants.TAG, "CARD_TYPE_ROAD_CONDITION"));
|
||||
MogoModulePaths.addModule(new MogoModule(CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
|
||||
DebugConfig.setNetMode( DebugConfig.NET_MODE_QA );
|
||||
MogoModulePaths.addModule( new MogoModule( OnLineCarConstants.TAG, OnLineCarConstants.MODULE_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
MogoModulePaths.addModule(new MogoModule(MediaConstants.TAG, MediaConstants.MODULE_TYPE));
|
||||
MogoModulePaths.addModule(new MogoModule(PushUIConstants.TAG, PushUIConstants.TAG));
|
||||
MogoModulePaths.addModule( new MogoModule( PushUIConstants.TAG, PushUIConstants.TAG ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
IMogoSocketManager mMogoSocketManager = (IMogoSocketManager) ARouter.getInstance().build(MogoServicePaths.PATH_SOCKET_MANAGER).navigation();
|
||||
mMogoSocketManager.init(getApplicationContext(), BuildConfig.APPLICATION_ID);
|
||||
IMogoSocketManager mMogoSocketManager = ( IMogoSocketManager ) ARouter.getInstance().build( MogoServicePaths.PATH_SOCKET_MANAGER ).navigation();
|
||||
mMogoSocketManager.init( getApplicationContext(), BuildConfig.APPLICATION_ID );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
MultiDex.install(base);
|
||||
protected void attachBaseContext( Context base ) {
|
||||
super.attachBaseContext( base );
|
||||
MultiDex.install( base );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
|
||||
USERNAME=xintai
|
||||
PASSWORD=xintai2018
|
||||
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
|
||||
RELEASE=false
|
||||
RELEASE=true
|
||||
# 模块版本
|
||||
DEMO_MODULE_MAP_VERSION=1.0.0-SNAPSHOT
|
||||
DEMO_MODULE_MAP2_VERSION=1.0.0-SNAPSHOT
|
||||
|
||||
@@ -141,7 +141,6 @@ public class RouteOverLayWrapper {
|
||||
}
|
||||
|
||||
public void updatePolyline( AMapNaviLocation aMapNaviLocation ) {
|
||||
Log.d( TAG, "updatePolyline" );
|
||||
if ( mIsRemoved ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ public class AppsModel {
|
||||
return 0;
|
||||
} else {
|
||||
if ( mPagedApps.get( totalPages - 1 ).size() == AppsConst.TOTAL_SIZE_EACH_PAGE ) {
|
||||
return totalPages + 1;
|
||||
} else {
|
||||
return totalPages;
|
||||
} else {
|
||||
return totalPages - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,11 @@ public class MogoModule {
|
||||
*/
|
||||
private String mName;
|
||||
|
||||
/**
|
||||
* 广播接收者
|
||||
*/
|
||||
private String mBroadcastAction;
|
||||
|
||||
/**
|
||||
* @param path 模块加载路径
|
||||
* @param name 模块名称
|
||||
@@ -45,4 +50,14 @@ public class MogoModule {
|
||||
this.mName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBroadcastAction() {
|
||||
return mBroadcastAction;
|
||||
}
|
||||
|
||||
public MogoModule setBroadcastAction( String broadcastAction ) {
|
||||
this.mBroadcastAction = broadcastAction;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
mCanvas.drawColor( Color.parseColor( "#EE0C0C0C" ) );
|
||||
mCanvas.drawColor( Color.parseColor( "#1F000000" ) );
|
||||
Bitmap mBitmap = BitmapFactory.decodeResource( getResources(), mFrames[mCurrentPos % mFrames.length] );
|
||||
|
||||
Paint paint = new Paint();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<gradient android:angle="270" android:centerColor="#7f000000" android:endColor="#1F000000" android:startColor="#CC000000" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="#EE0C0C0C"
|
||||
android:background="@drawable/module_ext_dw_shadow_frame_bkg"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/dp_70"
|
||||
android:paddingRight="@dimen/dp_70">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<string name="module_ext_str_dots">···</string>
|
||||
|
||||
<string name="module_map_str_search_hint">搜索目的地</string>
|
||||
<string name="module_map_str_upload_road_condition">上报\n路况</string>
|
||||
<string name="module_map_str_upload_road_condition">分享</string>
|
||||
<string name="module_ext_str_exit_navi">退出导航</string>
|
||||
<string name="module_ext_str_continue_navi">继续导航</string>
|
||||
</resources>
|
||||
|
||||
@@ -61,6 +61,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private View mApps;
|
||||
private View mEntrance;
|
||||
private FrameLayout mFloatingLayout;
|
||||
private View mShadowFrame;
|
||||
|
||||
/**
|
||||
* 主模块管控定位,可以向各个模块发送统一定位信息
|
||||
@@ -85,6 +86,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
try {
|
||||
mCurrentPosition = position;
|
||||
mMogoModuleHandler.setEnable( mCardModulesAdapter.getProvider( position ).getModuleName() );
|
||||
mShadowFrame.setVisibility( View.VISIBLE );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -107,6 +109,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mApps = findViewById( R.id.module_main_id_apps_fragment_container );
|
||||
mEntrance = findViewById( R.id.module_main_id_entrance_fragment_container );
|
||||
mFloatingLayout = findViewById( R.id.module_main_id_floating_view );
|
||||
mShadowFrame = findViewById( R.id.module_main_id_map_shadow_frame );
|
||||
|
||||
WindowViewHandler.init( mFloatingLayout );
|
||||
}
|
||||
@@ -117,6 +120,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mApps.setVisibility( View.GONE );
|
||||
mEntrance.setVisibility( View.GONE );
|
||||
mFloatingLayout.setVisibility( View.GONE );
|
||||
mShadowFrame.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
private void show() {
|
||||
@@ -125,6 +129,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mApps.setVisibility( View.VISIBLE );
|
||||
mEntrance.setVisibility( View.VISIBLE );
|
||||
mFloatingLayout.setVisibility( View.VISIBLE );
|
||||
mShadowFrame.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,7 +158,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
public void run() {
|
||||
Logger.d( TAG, "map loaded." + Thread.currentThread().getName() );
|
||||
loadModules();
|
||||
|
||||
mShadowFrame.setVisibility( View.VISIBLE );
|
||||
mMogoMapUIController.setPointToCenter( 0.66145, 0.590688 );
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -26,6 +26,11 @@ public class MogoFragmentManager implements IMogoFragmentManager {
|
||||
FragmentStack.getInstance().pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackSize() {
|
||||
return FragmentStack.getInstance().getStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAll() {
|
||||
FragmentStack.getInstance().clearAll();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<gradient android:angle="180" android:endColor="#232536" android:startColor="#001D1D1D" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -13,6 +13,13 @@
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_main_id_apps_fragment_container"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_map_shadow_frame"
|
||||
android:layout_width="@dimen/dp_720"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/module_main_dw_left_frame_bkg"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<item name="android:windowEnterAnimation">@null</item>
|
||||
<item name="android:windowExitAnimation">@null</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowBackground">#EE0C0C0C</item>
|
||||
<item name="android:windowBackground">#1F000000</item>
|
||||
<item name="android:windowTranslucentNavigation">false</item>
|
||||
<item name="android:windowAnimationStyle">@style/MainAnimation</item>
|
||||
</style>
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
@@ -30,159 +32,176 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MapPresenter extends Presenter<MapView>
|
||||
implements IMogoVoiceListener, IMogoVoiceCmdCallBack {
|
||||
public class MapPresenter extends Presenter< MapView >
|
||||
implements IMogoIntentListener, IMogoVoiceCmdCallBack {
|
||||
|
||||
private static final String TAG = "MapPresenter";
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoVoiceManager mMogoVoiceManager;
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
private IMogoSearchManager mSearchManager;
|
||||
|
||||
public MapPresenter(MapView view) {
|
||||
super(view);
|
||||
public MapPresenter( MapView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
mMogoMapService = (IMogoMapService) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_SERVICES_MAP)
|
||||
.navigation(getContext());
|
||||
mMogoVoiceManager = (IMogoVoiceManager) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_VOICE_MANAGER)
|
||||
.navigation(getContext());
|
||||
mSearchManager = (IMogoSearchManager) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_SEARCH_MANAGER)
|
||||
.navigation(getContext());
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance()
|
||||
.build( MogoServicePaths.PATH_SERVICES_MAP )
|
||||
.navigation( getContext() );
|
||||
mMogoIntentManager = ( IMogoIntentManager ) ARouter.getInstance()
|
||||
.build( MogoServicePaths.PATH_INTENT_MANAGER )
|
||||
.navigation( getContext() );
|
||||
mSearchManager = ( IMogoSearchManager ) ARouter.getInstance()
|
||||
.build( MogoServicePaths.PATH_SEARCH_MANAGER )
|
||||
.navigation( getContext() );
|
||||
|
||||
registerVoiceCmd();
|
||||
|
||||
IMogoNavi mogoNavi = mMogoMapService.getNavi(getContext());
|
||||
mogoNavi.setCalculatePathDisplayBounds(new Rect(
|
||||
ResourcesHelper.getDimensionPixelSize(getContext(), R.dimen.dp_730)
|
||||
+ WindowUtils.dip2px(getContext(), 80),
|
||||
ResourcesHelper.getDimensionPixelSize(getContext(), R.dimen.dp_120)
|
||||
+ WindowUtils.dip2px(getContext(), 80),
|
||||
WindowUtils.dip2px(getContext(), 80),
|
||||
WindowUtils.dip2px(getContext(), 80)
|
||||
));
|
||||
IMogoNavi mogoNavi = mMogoMapService.getNavi( getContext() );
|
||||
mogoNavi.setCalculatePathDisplayBounds( new Rect(
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.dp_730 )
|
||||
+ WindowUtils.dip2px( getContext(), 80 ),
|
||||
ResourcesHelper.getDimensionPixelSize( getContext(), R.dimen.dp_120 )
|
||||
+ WindowUtils.dip2px( getContext(), 80 ),
|
||||
WindowUtils.dip2px( getContext(), 80 ),
|
||||
WindowUtils.dip2px( getContext(), 80 )
|
||||
) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
super.onResume(owner);
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
registerVoiceCmd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
super.onPause(owner);
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
unregisterVoiceCmd();
|
||||
}
|
||||
|
||||
private void registerVoiceCmd() {
|
||||
if (VoiceConstants.sVoiceCmds.isEmpty()) {
|
||||
Logger.w(TAG, "no unwakeup words");
|
||||
if ( VoiceConstants.sVoiceCmds.isEmpty() ) {
|
||||
Logger.w( TAG, "no unwakeup words" );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Map.Entry< String, String[] > entry : VoiceConstants.sVoiceCmds.entrySet() ) {
|
||||
mMogoVoiceManager.registerIntentListener( entry.getKey(), this );
|
||||
mMogoIntentManager.registerIntentListener( entry.getKey(), this );
|
||||
// AIAssist.getInstance( getContext() ).registerUnWakeupCommand( entry.getKey(), entry.getValue(), this );
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterVoiceCmd() {
|
||||
if (VoiceConstants.sVoiceCmds.isEmpty()) {
|
||||
Logger.w(TAG, "no unwakeup words");
|
||||
if ( VoiceConstants.sVoiceCmds.isEmpty() ) {
|
||||
Logger.w( TAG, "no unwakeup words" );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Map.Entry< String, String[] > entry : VoiceConstants.sVoiceCmds.entrySet() ) {
|
||||
mMogoVoiceManager.unregisterIntentListener( entry.getKey() );
|
||||
mMogoIntentManager.unregisterIntentListener( entry.getKey() );
|
||||
// AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( entry.getKey(), this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived(String command, Intent intent) {
|
||||
if (TextUtils.isEmpty(command)) {
|
||||
public void onIntentReceived( String command, Intent intent ) {
|
||||
if ( TextUtils.isEmpty( command ) ) {
|
||||
return;
|
||||
}
|
||||
onCmdSelected(command);
|
||||
onCmdSelected( command );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected(String cmd) {
|
||||
switch (cmd) {
|
||||
public void onCmdSelected( String cmd ) {
|
||||
switch ( cmd ) {
|
||||
case VoiceConstants.CMD_MAP_TRAFFIC_MODE:
|
||||
mView.getUIController().setTrafficEnabled(true);
|
||||
case VoiceConstants.CMD_MAP_TRAFFIC_MODE_UN_WAKEUP:
|
||||
mView.getUIController().setTrafficEnabled( true );
|
||||
mSearchManager.showSearch();
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已打开", null);
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已打开", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE:
|
||||
mView.getUIController().setTrafficEnabled(false);
|
||||
case VoiceConstants.CMD_MAP_UN_TRAFFIC_MODE_UN_WAKEUP:
|
||||
mView.getUIController().setTrafficEnabled( false );
|
||||
mSearchManager.showMain();
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已关闭", null);
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已关闭", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_ZOOM_IN:
|
||||
case VoiceConstants.CMD_MAP_ZOOM_IN_UN_WAKEUP:
|
||||
mView.getUIController().changeZoom( true );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已放大", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_ZOOM_OUT:
|
||||
case VoiceConstants.CMD_MAP_ZOOM_OUT_UN_WAKEUP:
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已缩小", null );
|
||||
mView.getUIController().changeZoom( false );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_2D:
|
||||
case VoiceConstants.CMD_MAP_2D_UN_WAKEUP:
|
||||
case VoiceConstants.CMD_MAP_NORTH_UP_MODE:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.NorthUP_2D);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_NORTH_UP_MODE_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_3D:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.CarUp_3D);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_3D_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.CarUp_3D );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_DAY_TIME_MODE:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.Type_Light);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_DAY_TIME_MODE_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.Type_Light );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_GO_COMPANY:
|
||||
case VoiceConstants.CMD_MAP_GO_COMPANY_UN_WAKEUP:
|
||||
mSearchManager.goCompany();
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_GO_HOME:
|
||||
case VoiceConstants.CMD_MAP_GO_HOME_UN_WAKEUP:
|
||||
mSearchManager.goHome();
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_HISTORY:
|
||||
case VoiceConstants.CMD_MAP_HISTORY_UN_WAKEUP:
|
||||
mSearchManager.showSearch();
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_STOP_NAVI_MODE:
|
||||
case VoiceConstants.CMD_MAP_STOP_NAVI_MODE_UN_WAKEUP:
|
||||
mSearchManager.showMain();
|
||||
break;
|
||||
|
||||
case VoiceConstants.CMD_MAP_NIGHT_MODE:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.Type_Night);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_NIGHT_MODE_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.Type_Night );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.Type_AUTO_LIGHT_Night);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_AUTO_LIGHT_NIGHT_MODE_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.Type_AUTO_LIGHT_Night );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_DISPLAY_OVERVIEW_MODE:
|
||||
case VoiceConstants.CMD_MAP_DISPLAY_OVERVIEW_MODE_UN_WAKEUP:
|
||||
mView.getUIController().displayOverview();
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE:
|
||||
case VoiceConstants.CMD_MAP_CONTINUE_NAVI_MODE_UN_WAKEUP:
|
||||
mView.getUIController().recoverLockMode();
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
case VoiceConstants.CMD_MAP_CAR_UP_MODE:
|
||||
mView.getUIController().changeMapMode(EnumMapUI.CarUp_2D);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("已切换", null);
|
||||
case VoiceConstants.CMD_MAP_CAR_UP_MODE_UN_WAKEUP:
|
||||
mView.getUIController().changeMapMode( EnumMapUI.CarUp_2D );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "已切换", null );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -190,22 +209,22 @@ public class MapPresenter extends Presenter<MapView>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdAction(String speakText) {
|
||||
public void onCmdAction( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdCancel(String speakText) {
|
||||
public void onCmdCancel( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakEnd(String speakText) {
|
||||
public void onSpeakEnd( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakSelectTimeOut(String speakText) {
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView {
|
||||
super.onCreate(savedInstanceState)
|
||||
category = arguments?.getString("category")
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, false
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY, true
|
||||
)
|
||||
mSearchPresenter = CategoryPresenter(this)
|
||||
lifecycle.addObserver(mSearchPresenter)
|
||||
|
||||
@@ -74,8 +74,6 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
iv_navi_back.setOnClickListener {
|
||||
SearchServiceHolder.fragmentManager.pop()
|
||||
SearchServiceHolder.getNavi()
|
||||
.clearCalculatePaths()
|
||||
}
|
||||
|
||||
tv_navi_navi.text = getString(R.string.start_navi)
|
||||
@@ -112,16 +110,20 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
SearchServiceHolder.getNavi()
|
||||
.itemClickInteraction.onItemClicked(item.tagId)
|
||||
}
|
||||
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
SearchServiceHolder.listenerCenter.unregisterMogoNaviListener(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT
|
||||
)
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT, false
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT, false
|
||||
)
|
||||
SearchServiceHolder.getNavi()
|
||||
.clearCalculatePaths()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.mogo.module.navi.constants.DataConstants
|
||||
import com.mogo.module.navi.constants.SearchServiceHolder
|
||||
import com.mogo.module.navi.database.AppDataBase
|
||||
import com.mogo.module.navi.ui.base.BaseFragment
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@@ -86,15 +87,14 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
)
|
||||
SearchServiceHolder.getMapUIController()
|
||||
.showMyLocation(false)
|
||||
moveMapToCenter()
|
||||
|
||||
SearchServiceHolder.getGeoSearcher()
|
||||
.setGeoSearchListener(this)
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, false)
|
||||
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, true)
|
||||
|
||||
SearchServiceHolder.getMarkerManger().removeMarkers()
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
@@ -137,7 +137,8 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
et_navi_search.setText(getString(string.drag_map_to_choose))
|
||||
var location = SearchServiceHolder.getMapUIController()
|
||||
.windowCenterLocation
|
||||
if (addMarker == null) {
|
||||
moveMapToCenter()
|
||||
UiThreadHandler.postDelayed({
|
||||
var decodeResource = BitmapFactory.decodeResource(resources, R.mipmap.icon_choose_position2)
|
||||
val options = MogoMarkerOptions()
|
||||
.icon(decodeResource)
|
||||
@@ -146,13 +147,12 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
.anchor(0.5f, 1f)
|
||||
.longitude(location?.lng ?: 0.0)
|
||||
addMarker = SearchServiceHolder.getMarkerManger()
|
||||
.addMarker(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
.addMarker(MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, options)
|
||||
|
||||
var locationPointInScreen = SearchServiceHolder.getMapUIController()
|
||||
.getLocationPointInScreen(location)
|
||||
.getLocationPointInScreen(location)
|
||||
addMarker?.setPositionByPixels(locationPointInScreen)
|
||||
}
|
||||
|
||||
}, 500L)
|
||||
}
|
||||
|
||||
fun insert(searchPoi: SearchPoi) {
|
||||
@@ -179,7 +179,12 @@ class SettingAddressFragment : BaseFragment(), IMogoGeoSearchListener {
|
||||
addMarker?.destroy()
|
||||
|
||||
SearchServiceHolder.statusManager.setSearchUIShow(
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, true)
|
||||
MogoModulePaths.PATH_FRAGMENT_SETTING_HOME, false)
|
||||
|
||||
if (SearchServiceHolder.fragmentManager.stackSize == 0) {
|
||||
moveMapToRight()
|
||||
SearchServiceHolder.getMapUIController().showMyLocation(true)
|
||||
}
|
||||
|
||||
// moveMapToRight()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.service;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -31,10 +32,12 @@ import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.receiver.AIAssistReceiver;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.service.refresh.AutoRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
@@ -43,6 +46,8 @@ import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
@@ -58,7 +63,8 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
IMogoMapListener,
|
||||
IMogoLocationListener,
|
||||
IMogoNaviListener,
|
||||
IMogoStatusChangedListener {
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener {
|
||||
|
||||
private static final String TAG = "MogoRefreshStrategyProvider";
|
||||
|
||||
@@ -81,7 +87,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
*/
|
||||
boolean mIsVertical = false;
|
||||
|
||||
private AIAssistReceiver mAIAssistReceiver;
|
||||
private MogoReceiver mAIAssistReceiver;
|
||||
|
||||
/**
|
||||
* 手动刷新策略
|
||||
@@ -95,6 +101,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
@@ -230,6 +237,10 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
registerCenter.registerMogoLocationListener( getModuleName(), this );
|
||||
registerCenter.registerMogoNaviListener( getModuleName(), this );
|
||||
registerCenter.registerMogoMapListener( getModuleName(), this );
|
||||
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( context );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ADAS_ACTION, this );
|
||||
|
||||
}
|
||||
|
||||
private void registerAIReceiver( Context context ) {
|
||||
@@ -240,9 +251,18 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
if ( modules.isEmpty() || modules == null ) {
|
||||
return;
|
||||
}
|
||||
mAIAssistReceiver = new AIAssistReceiver( context );
|
||||
mAIAssistReceiver = new MogoReceiver( context );
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction( AIAssistReceiver.ACTION );
|
||||
if ( modules != null && !modules.isEmpty() ) {
|
||||
for ( MogoModule module : modules ) {
|
||||
if ( TextUtils.isEmpty( module.getBroadcastAction() ) ) {
|
||||
continue;
|
||||
}
|
||||
filter.addAction( module.getBroadcastAction() );
|
||||
}
|
||||
}
|
||||
filter.addAction( MogoReceiver.VOICE_ACTION );
|
||||
filter.addAction( MogoReceiver.ADAS_ACTION );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
@@ -371,6 +391,8 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
notifyRefreshData( latLng, getQueryRadius(), mCustomRefreshCallback );
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
}
|
||||
} else {
|
||||
mLastZoomLevel = zoom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,4 +516,15 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
public IMogoMarkerClickListener getMarkerClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String command, Intent intent ) {
|
||||
if ( MogoReceiver.ADAS_ACTION.equals( command ) ) {
|
||||
if ( intent == null ) {
|
||||
return;
|
||||
}
|
||||
int status = intent.getIntExtra( MogoReceiver.PARAM_ADAS_STATUS, 0 );
|
||||
mStatusManager.setADASUIShow( getModuleName(), status == 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int DECREASE_INTERVAL = 1_000;
|
||||
|
||||
|
||||
/**
|
||||
* 卡片 车聊聊
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ public class RefreshModel {
|
||||
if ( mRefreshApiService != null ) {
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = 5;
|
||||
refreshBody.limit = 20;
|
||||
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
|
||||
refreshBody.radius = radius;
|
||||
query.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.module.service.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-03
|
||||
* <p>
|
||||
* 语音助手广播接收者
|
||||
*/
|
||||
public class AIAssistReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION = "com.zhidao.speech.awake.notify";
|
||||
public static final String PARAM_COMMAND = "command";
|
||||
|
||||
private static final String TAG = "AIAssistReceiver";
|
||||
|
||||
|
||||
private IMogoVoiceManager mMogoVoiceManager;
|
||||
|
||||
public AIAssistReceiver( Context context ) {
|
||||
mMogoVoiceManager = ( IMogoVoiceManager ) ARouter.getInstance().build( MogoServicePaths.PATH_VOICE_MANAGER ).navigation( context );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
Logger.i( TAG, "receive ai assist intent" );
|
||||
final String action = intent.getAction();
|
||||
if ( TextUtils.equals( ACTION, action ) ) {
|
||||
String cmd = intent.getStringExtra( PARAM_COMMAND );
|
||||
if ( !TextUtils.isEmpty( cmd ) ) {
|
||||
mMogoVoiceManager.invoke( cmd, intent );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.mogo.module.service.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-03
|
||||
* <p>
|
||||
* 广播接收者
|
||||
*/
|
||||
public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "MogoReceiver";
|
||||
|
||||
/**
|
||||
* 语音
|
||||
*/
|
||||
public static final String VOICE_ACTION = "com.zhidao.speech.awake.notify";
|
||||
public static final String PARAM_COMMAND = "command";
|
||||
|
||||
/**
|
||||
* ADAS
|
||||
*/
|
||||
public static final String ADAS_ACTION = "com.mogo.launcher.adas";
|
||||
// ADAS 状态 0 - 关闭 1 - 打开
|
||||
public static final String PARAM_ADAS_STATUS = "adas_drawer_status";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver( Context context ) {
|
||||
mMogoIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( context );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
final String action = intent.getAction();
|
||||
Logger.i( TAG, "receive intent action: %s", action );
|
||||
if ( TextUtils.equals( VOICE_ACTION, action ) ) {
|
||||
String cmd = intent.getStringExtra( PARAM_COMMAND );
|
||||
if ( !TextUtils.isEmpty( cmd ) ) {
|
||||
mMogoIntentManager.invoke( cmd, intent );
|
||||
}
|
||||
} else {
|
||||
mMogoIntentManager.invoke( action, intent );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public class TanluConstants {
|
||||
|
||||
public static final String TAG = "/tanlu/ui";
|
||||
public static final String NAVI_INFO = "navi_info";
|
||||
public static final String MODEL_NAME = "mogo-module-tanlu";
|
||||
public static final String MODEL_NAME = "CARD_TYPE_ROAD_CONDITION";
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.tanlu.callback.AlongTheWayCallback;
|
||||
import com.mogo.module.tanlu.callback.RoadLineCallback;
|
||||
import com.mogo.module.tanlu.callback.VoiceSearchCallback;
|
||||
@@ -83,7 +84,7 @@ import static com.mogo.module.tanlu.video.VideoInitKt.initVideo;
|
||||
* @description 探路卡片
|
||||
* @since 2020-01-02
|
||||
*/
|
||||
public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
public class TanluCardViewFragment extends MvpFragment< IView, Presenter< IView > >
|
||||
implements IView,
|
||||
IMogoMarkerClickListener,
|
||||
IMogoModuleLifecycle,
|
||||
@@ -112,6 +113,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
private String mVideoUrl = "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";
|
||||
private String mImageUrl = "https://oimagec4.ydstatic.com/image?id=-5397300958976572132&product=adpublish&w=520&h=347";
|
||||
private String mTitle = "";
|
||||
private long mGenerateTime = 0;
|
||||
private IMogoImageloader mogoImageloader;
|
||||
private TextView mPreviousTv;
|
||||
private TextView mNextTv;
|
||||
@@ -122,11 +125,11 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
private TextView mDistanceTv;
|
||||
private TextView mTimeTv;
|
||||
|
||||
private List<MarkerExploreWay> markerExploreWayList = new ArrayList<>();
|
||||
private List< MarkerExploreWay > markerExploreWayList = new ArrayList<>();
|
||||
private int currentPosition = 0; //卡片媒体当前位置
|
||||
private Bitmap mMarkerIcon;
|
||||
private TanluModelData mTanluModelData;
|
||||
private List<MogoLatLng> passedByPoints;
|
||||
private List< MogoLatLng > passedByPoints;
|
||||
private IMogoRegisterCenter mMogoRegisterCenter;
|
||||
|
||||
|
||||
@@ -138,54 +141,57 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
@Override
|
||||
protected void initViews() {
|
||||
initVideo();
|
||||
simpleCoverVideoPlayer = findViewById(R.id.video_player_main);
|
||||
autoZoomInImageView = findViewById(R.id.tanlu_photo_imageView);
|
||||
mPreviousTv = findViewById(R.id.tv_previous_res);
|
||||
mNextTv = findViewById(R.id.tv_next_res);
|
||||
mRootLayout = findViewById(R.id.layout_data_show);
|
||||
mEmptyLayout = findViewById(R.id.layout_empty_data_show);
|
||||
mEmptyTv = findViewById(R.id.tv_main_empty);
|
||||
mAddressTv = findViewById(R.id.tv_information_media_content);
|
||||
mDistanceTv = findViewById(R.id.tv_distance_video);
|
||||
mTimeTv = findViewById(R.id.tv_information_media_time);
|
||||
simpleCoverVideoPlayer = findViewById( R.id.video_player_main );
|
||||
autoZoomInImageView = findViewById( R.id.tanlu_photo_imageView );
|
||||
mPreviousTv = findViewById( R.id.tv_previous_res );
|
||||
mNextTv = findViewById( R.id.tv_next_res );
|
||||
mRootLayout = findViewById( R.id.layout_data_show );
|
||||
mEmptyLayout = findViewById( R.id.layout_empty_data_show );
|
||||
mEmptyTv = findViewById( R.id.tv_main_empty );
|
||||
mAddressTv = findViewById( R.id.tv_information_media_content );
|
||||
mDistanceTv = findViewById( R.id.tv_distance_video );
|
||||
mTimeTv = findViewById( R.id.tv_information_media_time );
|
||||
|
||||
mPreviousTv.setOnClickListener(this);
|
||||
mNextTv.setOnClickListener(this);
|
||||
mEmptyTv.setOnClickListener(this);
|
||||
mPreviousTv.setOnClickListener( this );
|
||||
mNextTv.setOnClickListener( this );
|
||||
mEmptyTv.setOnClickListener( this );
|
||||
|
||||
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
|
||||
autoZoomInImageView.setVisibility(View.GONE);
|
||||
simpleCoverVideoPlayer.setVisibility( View.VISIBLE );
|
||||
autoZoomInImageView.setVisibility( View.GONE );
|
||||
|
||||
//视频配置 TODO 需要去掉
|
||||
gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() {
|
||||
// gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
// .build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Logger.d(TAG, "simpleCoverVideoPlayer onClick -------> ");
|
||||
FullMediaActivity.Companion.launch(getActivity(), mVideoUrl, mImageUrl, "东城区环球贸易中心", 1300000300);
|
||||
public void onClick( View view ) {
|
||||
Logger.d( TAG, "simpleCoverVideoPlayer onClick -------> " );
|
||||
FullMediaActivity.Companion.launch( getActivity(), mVideoUrl, mImageUrl, mTitle, mGenerateTime );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
private void initInterface() {
|
||||
//图片配置
|
||||
mogoImageloader = (IMogoImageloader) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_IMAGE_LOADER).navigation();
|
||||
mogoImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation();
|
||||
//地图marker
|
||||
mMogoMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(getActivity());
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getActivity() );
|
||||
//切换卡片操作
|
||||
iMogoCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation(getActivity());
|
||||
iMogoCardManager = ( IMogoCardManager ) ARouter.getInstance().build( MogoServicePaths.PATH_CARD_MANAGER ).navigation( getActivity() );
|
||||
|
||||
mMogoRegisterCenter = (IMogoRegisterCenter) ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation(getContext());
|
||||
mMogoRegisterCenter = ( IMogoRegisterCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_REGISTER_CENTER ).navigation( getContext() );
|
||||
|
||||
|
||||
mMogoRegisterCenter.registerMogoModuleLifecycle( TanluConstants.MODEL_NAME, this );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getViewLifecycleOwner().getLifecycle().addObserver(mPresenter);
|
||||
EventBus.getDefault().register(this);
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
getViewLifecycleOwner().getLifecycle().addObserver( mPresenter );
|
||||
EventBus.getDefault().register( this );
|
||||
initInterface();
|
||||
initModelData();
|
||||
handleRoadLineMessage();
|
||||
@@ -197,8 +203,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
private void initModelData() {
|
||||
if (mTanluModelData == null) {
|
||||
mTanluModelData = new TanluModelData(getContext());
|
||||
if ( mTanluModelData == null ) {
|
||||
mTanluModelData = new TanluModelData( getContext() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +212,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
* 初始化导航 TODO
|
||||
*/
|
||||
private void initMap() {
|
||||
mMogoRegisterCenter.registerMogoNaviListener(TanluConstants.MODEL_NAME, new IMogoNaviListener() {
|
||||
mMogoRegisterCenter.registerMogoNaviListener( TanluConstants.MODEL_NAME, new IMogoNaviListener() {
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
@@ -218,7 +224,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
|
||||
}
|
||||
|
||||
@@ -242,31 +248,52 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
//监听marker点击
|
||||
mMogoRegisterCenter.registerMogoMarkerClickListener(TanluConstants.MODEL_NAME, new IMogoMarkerClickListener() {
|
||||
mMogoRegisterCenter.registerMogoMarkerClickListener( TanluConstants.MODEL_NAME, new IMogoMarkerClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
//点击marker以后,确认他的位置?然后点击下一个操作 TODO
|
||||
MarkerExploreWay exploreWay = (MarkerExploreWay) marker.getObject();
|
||||
handleData(exploreWay);
|
||||
MarkerExploreWay exploreWay = extractFromMarker(marker);
|
||||
if ( exploreWay == null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( exploreWay.getFileType() == 0 ) { //图片
|
||||
refreshPhotoData( exploreWay );
|
||||
} else if ( exploreWay.getFileType() == 1 ) { //视频
|
||||
handleData( exploreWay );
|
||||
}
|
||||
|
||||
//更新位置currentPosition
|
||||
for (int i = 0; i < markerExploreWayList.size(); i++) {
|
||||
if (markerExploreWayList.get(i).getAddr().equals(exploreWay.getAddr())) {
|
||||
for ( int i = 0; i < markerExploreWayList.size(); i++ ) {
|
||||
if ( markerExploreWayList.get( i ) == exploreWay ) {
|
||||
currentPosition = i;
|
||||
break;
|
||||
}
|
||||
Logger.d(TAG, "onMarkerClicked currentPosition = " + currentPosition);
|
||||
Logger.d( TAG, "onMarkerClicked currentPosition = " + currentPosition );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
private MarkerExploreWay extractFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( marker.getObject() instanceof MarkerShowEntity ) {
|
||||
MarkerShowEntity showEntity = ( ( MarkerShowEntity ) marker.getObject() );
|
||||
if ( showEntity.getBindObj() instanceof MarkerExploreWay ) {
|
||||
return ( ( MarkerExploreWay ) showEntity.getBindObj() );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理路线数据信息,msgType
|
||||
@@ -296,66 +323,66 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
* @param view
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick( View view ) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.tv_previous_res) { //上一个
|
||||
//判断是图片还是视频,第一个时,上一个不可点击
|
||||
// Logger.d(TAG, " tv_previous_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
// if (currentPosition < 0) {
|
||||
// return;
|
||||
// }
|
||||
// currentPosition--;
|
||||
// Logger.d(TAG, " tv_previous_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
// if (markerExploreWayList.size() > currentPosition && currentPosition >= 0) {
|
||||
// handleData(markerExploreWayList.get(currentPosition));
|
||||
// }
|
||||
if ( id == R.id.tv_previous_res ) { //上一个
|
||||
// 判断是图片还是视频,第一个时,上一个不可点击
|
||||
Logger.d(TAG, " tv_previous_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
if (currentPosition < 0) {
|
||||
return;
|
||||
}
|
||||
currentPosition--;
|
||||
Logger.d(TAG, " tv_previous_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
if (markerExploreWayList.size() > currentPosition && currentPosition >= 0) {
|
||||
handleData(markerExploreWayList.get(currentPosition));
|
||||
}
|
||||
|
||||
// getRoadLineData();
|
||||
// getVoiceControlRoadData("中关村");
|
||||
// getNavigationLineData();
|
||||
getNaviRoadLineInfo();
|
||||
// getNaviRoadLineInfo();
|
||||
|
||||
} else if (id == R.id.tv_next_res) { //下一个
|
||||
} else if ( id == R.id.tv_next_res ) { //下一个
|
||||
//判断是图片还是视频,最后一个时,下一个不可点击
|
||||
Logger.d(TAG, " tv_next_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
if (currentPosition > markerExploreWayList.size()) {
|
||||
Logger.d( TAG, " tv_next_res --1-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size() );
|
||||
if ( currentPosition > markerExploreWayList.size() ) {
|
||||
return;
|
||||
}
|
||||
currentPosition++;
|
||||
Logger.d(TAG, " tv_next_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size());
|
||||
if (markerExploreWayList.size() > currentPosition) {
|
||||
handleData(markerExploreWayList.get(currentPosition));
|
||||
Logger.d( TAG, " tv_next_res --2-> currentPosition =" + currentPosition + ">> size= " + markerExploreWayList.size() );
|
||||
if ( markerExploreWayList.size() > currentPosition ) {
|
||||
handleData( markerExploreWayList.get( currentPosition ) );
|
||||
}
|
||||
|
||||
} else if (id == R.id.tv_main_empty) { //TODO上报路况,逻辑
|
||||
Logger.d(TAG, "tv_main_empty click -----> ");
|
||||
sendShareReceiver("1");
|
||||
} else if ( id == R.id.tv_main_empty ) { //TODO上报路况,逻辑
|
||||
Logger.d( TAG, "tv_main_empty click -----> " );
|
||||
sendShareReceiver( "1" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送广播
|
||||
*/
|
||||
private void sendShareReceiver(String type) {
|
||||
Logger.d("liyz", "LaucherShareDialog sendShareReceiver ---->");
|
||||
private void sendShareReceiver( String type ) {
|
||||
Logger.d( "liyz", "LaucherShareDialog sendShareReceiver ---->" );
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("com.zhidao.roadcondition.share");
|
||||
intent.putExtra("type", type);
|
||||
getContext().sendBroadcast(intent);
|
||||
intent.setAction( "com.zhidao.roadcondition.share" );
|
||||
intent.putExtra( "type", type );
|
||||
getContext().sendBroadcast( intent );
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行图片动画
|
||||
*/
|
||||
private void handleImageAnimation() {
|
||||
autoZoomInImageView.post(new Runnable() {
|
||||
autoZoomInImageView.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//放大增量是0.3,放大时间是1000毫秒,放大开始时间是600毫秒以后
|
||||
autoZoomInImageView.init()
|
||||
.startZoomInByScaleDeltaAndDuration(0.2f, 1000, 500);
|
||||
.startZoomInByScaleDeltaAndDuration( 0.2f, 1000, 500 );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +392,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -374,85 +401,90 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
*
|
||||
* @param exploreWay
|
||||
*/
|
||||
private void handleData(MarkerExploreWay exploreWay) {
|
||||
if (exploreWay != null ) {
|
||||
if (exploreWay.getFileType()==0) { //图片
|
||||
refreshPhotoData(exploreWay);
|
||||
} else if (exploreWay.getFileType()==1) { //视频
|
||||
refreshVideoData(exploreWay);
|
||||
private void handleData( MarkerExploreWay exploreWay ) {
|
||||
if ( exploreWay != null ) {
|
||||
if ( exploreWay.getFileType() == 0 ) { //图片
|
||||
refreshPhotoData( exploreWay );
|
||||
} else if ( exploreWay.getFileType() == 1 ) { //视频
|
||||
refreshVideoData( exploreWay );
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "handleData exploreWay == null ");
|
||||
Logger.e( TAG, "handleData exploreWay == null " );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单个视频数据,更新位置positon
|
||||
*/
|
||||
private void refreshVideoData(MarkerExploreWay markerExploreWay) {
|
||||
if (markerExploreWay.getItems() == null) {
|
||||
private void refreshVideoData( MarkerExploreWay markerExploreWay ) {
|
||||
if ( markerExploreWay.getItems() == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (markerExploreWay.getItems().size() == 0) {
|
||||
if ( markerExploreWay.getItems().size() == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
String videoUrl = markerExploreWay.getItems().get(0).getUrl();
|
||||
mAddressTv.setText(markerExploreWay.getAddr());
|
||||
mDistanceTv.setText(handleDistance(markerExploreWay.getDistance()));
|
||||
mTimeTv.setText(formatDate(markerExploreWay.getGenerateTime()));
|
||||
String videoUrl = markerExploreWay.getItems().get( 0 ).getUrl();
|
||||
mImageUrl = markerExploreWay.getItems().get( 0 ).getThumbnail();
|
||||
mGenerateTime = markerExploreWay.getGenerateTime();
|
||||
mTitle = markerExploreWay.getAddr();
|
||||
mAddressTv.setText( markerExploreWay.getAddr() );
|
||||
mDistanceTv.setText( handleDistance( markerExploreWay.getDistance() ) );
|
||||
mTimeTv.setText( formatDate( markerExploreWay.getGenerateTime() ) );
|
||||
//判断是图片还是视频,第一个时,上一个不可点击
|
||||
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
|
||||
autoZoomInImageView.setVisibility(View.GONE);
|
||||
simpleCoverVideoPlayer.setVisibility( View.VISIBLE );
|
||||
//视频配置
|
||||
gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
|
||||
mVideoUrl = videoUrl;
|
||||
gsyVideoOptionBuilder.setUrl( videoUrl ).setCacheWithPlay( false ).setPlayTag( TAG )
|
||||
.build( simpleCoverVideoPlayer );
|
||||
if ( mImageUrl == null ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单个图片数据
|
||||
*/
|
||||
private void refreshPhotoData(MarkerExploreWay markerExploreWay) {
|
||||
if (markerExploreWay.getItems() == null) {
|
||||
private void refreshPhotoData( MarkerExploreWay markerExploreWay ) {
|
||||
if ( markerExploreWay.getItems() == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (markerExploreWay.getItems().size() == 0) {
|
||||
if ( markerExploreWay.getItems().size() == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAddressTv.setText(markerExploreWay.getAddr());
|
||||
mDistanceTv.setText(handleDistance(markerExploreWay.getDistance()));
|
||||
mTimeTv.setText(formatDate(markerExploreWay.getGenerateTime()));
|
||||
String thumbnailUrl = markerExploreWay.getItems().get(0).getThumbnail();
|
||||
Logger.d(TAG, "refreshPhotoData thumbnailUrl ------>" + thumbnailUrl);
|
||||
autoZoomInImageView.setVisibility(View.VISIBLE);
|
||||
simpleCoverVideoPlayer.setVisibility(View.GONE);
|
||||
mogoImageloader.downloadImage(getActivity(), thumbnailUrl, new IMogoImageLoaderListener() {
|
||||
mAddressTv.setText( markerExploreWay.getAddr() );
|
||||
mDistanceTv.setText( handleDistance( markerExploreWay.getDistance() ) );
|
||||
mTimeTv.setText( formatDate( markerExploreWay.getGenerateTime() ) );
|
||||
String thumbnailUrl = markerExploreWay.getItems().get( 0 ).getUrl();
|
||||
Logger.d( TAG, "refreshPhotoData thumbnailUrl ------>" + thumbnailUrl );
|
||||
autoZoomInImageView.setVisibility( View.VISIBLE );
|
||||
simpleCoverVideoPlayer.setVisibility( View.GONE );
|
||||
mogoImageloader.downloadImage( getActivity(), thumbnailUrl, new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(Bitmap bitmap) {
|
||||
autoZoomInImageView.setImageBitmap(bitmap);
|
||||
public void onCompleted( Bitmap bitmap ) {
|
||||
autoZoomInImageView.setImageBitmap( bitmap );
|
||||
//动画
|
||||
handleImageAnimation();
|
||||
// handleImageAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
Logger.e(TAG, "onFailure ------>" + e);
|
||||
public void onFailure( Exception e ) {
|
||||
Logger.e( TAG, "onFailure ------>" + e );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Presenter createPresenter() {
|
||||
return new Presenter(this) {
|
||||
return new Presenter( this ) {
|
||||
};
|
||||
}
|
||||
|
||||
@@ -462,38 +494,42 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
*/
|
||||
@Override
|
||||
public void onPerform() {
|
||||
Logger.d(TAG, "tanlu卡片 有效 ---->");
|
||||
mMarkerManager = mMogoMapService.getMarkerManager(getActivity());
|
||||
List<IMogoMarker> markers = mMarkerManager.getMarkers("CARD_TYPE_ROAD_CONDITION");
|
||||
if (markers != null && markers.size() > 0) {
|
||||
mEmptyLayout.setVisibility(View.GONE);
|
||||
mRootLayout.setVisibility(View.VISIBLE);
|
||||
Logger.d(TAG, "onPerform markers.size() =" + markers.size());
|
||||
for (int i = 0; i < markers.size(); i++) {
|
||||
markerExploreWayList.add((MarkerExploreWay) markers.get(i).getObject());
|
||||
Logger.d( TAG, "tanlu卡片 有效 ---->" );
|
||||
mMarkerManager = mMogoMapService.getMarkerManager( getActivity() );
|
||||
List< IMogoMarker > markers = mMarkerManager.getMarkers( TanluConstants.MODEL_NAME );
|
||||
if ( markers != null && markers.size() > 0 ) {
|
||||
mEmptyLayout.setVisibility( View.GONE );
|
||||
mRootLayout.setVisibility( View.VISIBLE );
|
||||
Logger.d( TAG, "onPerform markers.size() =" + markers.size() );
|
||||
for ( int i = 0; i < markers.size(); i++ ) {
|
||||
MarkerExploreWay exploreWay = extractFromMarker(markers.get( i ));
|
||||
if ( exploreWay == null ) {
|
||||
break;
|
||||
}
|
||||
markerExploreWayList.add(exploreWay );
|
||||
}
|
||||
|
||||
if (markers.size() == 1) {
|
||||
mPreviousTv.setVisibility(View.GONE);
|
||||
mNextTv.setVisibility(View.GONE);
|
||||
if ( markers.size() == 1 ) {
|
||||
mPreviousTv.setVisibility( View.GONE );
|
||||
mNextTv.setVisibility( View.GONE );
|
||||
} else {
|
||||
mPreviousTv.setVisibility(View.VISIBLE);
|
||||
mNextTv.setVisibility(View.VISIBLE);
|
||||
mPreviousTv.setVisibility( View.VISIBLE );
|
||||
mNextTv.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
//展示第一个数据
|
||||
MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
|
||||
if (markerExploreWay != null) {
|
||||
if (markerExploreWay.getFileType()==0) { //图片
|
||||
refreshPhotoData(markerExploreWay);
|
||||
} else if (markerExploreWay.getFileType()==1) { //视频
|
||||
refreshVideoData(markerExploreWay);
|
||||
MarkerExploreWay markerExploreWay = markerExploreWayList.get( 0 );
|
||||
if ( markerExploreWay != null ) {
|
||||
if ( markerExploreWay.getFileType() == 0 ) { //图片
|
||||
refreshPhotoData( markerExploreWay );
|
||||
} else if ( markerExploreWay.getFileType() == 1 ) { //视频
|
||||
refreshVideoData( markerExploreWay );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mEmptyLayout.setVisibility(View.VISIBLE);
|
||||
mRootLayout.setVisibility(View.GONE);
|
||||
mEmptyTv.setText(Html.fromHtml(getContext().getString(R.string.main_empty_content)));
|
||||
mEmptyLayout.setVisibility( View.VISIBLE );
|
||||
mRootLayout.setVisibility( View.GONE );
|
||||
mEmptyTv.setText( Html.fromHtml( getContext().getString( R.string.main_empty_content ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +538,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Logger.d(TAG, "tanlu卡片 无效 ----->");
|
||||
Logger.d( TAG, "tanlu卡片 无效 ----->" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -516,32 +552,32 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(MotionEvent motionEvent) {
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
// Logger.d( TAG, "地图触摸事件" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick(MogoPoi poi) {
|
||||
if (poi != null) {
|
||||
TipToast.shortTip(poi.getName());
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
if ( poi != null ) {
|
||||
TipToast.shortTip( poi.getName() );
|
||||
}
|
||||
TanluServiceHandler.getPoiSearch().searchPOIIdAsyn(poi.getPoiId());
|
||||
TanluServiceHandler.getPoiSearch().searchPOIIdAsyn( poi.getPoiId() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPoiSearched(MogoPoiResult result, int errorCode) {
|
||||
public void onPoiSearched( MogoPoiResult result, int errorCode ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPoiItemSearched(MogoPoiItem item, int errorCode) {
|
||||
if (item == null) {
|
||||
public void onPoiItemSearched( MogoPoiItem item, int errorCode ) {
|
||||
if ( item == null ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
// if (location.getErrCode() == 0) {
|
||||
// Logger.d(TAG, "onLocationChanged 当前位置 -->" + location.getAddress());
|
||||
// } else {
|
||||
@@ -550,32 +586,32 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(MogoLatLng latLng) {
|
||||
public void onMapClick( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap(boolean isLock) {
|
||||
public void onLockMap( boolean isLock ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged(EnumMapUI ui) {
|
||||
Logger.d(TAG, ui.name());
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
Logger.d( TAG, ui.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged(MogoLatLng location, float zoom, float tilt, float bearing) {
|
||||
public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
EventBus.getDefault().unregister(this);
|
||||
getViewLifecycleOwner().getLifecycle().removeObserver(mPresenter);
|
||||
TanluServiceHandler.getLocationClient().removeLocationListener(this);
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(TanluConstants.MODEL_NAME);
|
||||
EventBus.getDefault().unregister( this );
|
||||
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
||||
TanluServiceHandler.getLocationClient().removeLocationListener( this );
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener( TanluConstants.MODEL_NAME );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,35 +619,35 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMarkerInfo(final MarkerInfo event) {
|
||||
Logger.d(TAG, "onMarkerInfo ------>");
|
||||
mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_poi_location);
|
||||
mogoImageloader.downloadImage(getActivity(), event.imageUrl, new IMogoImageLoaderListener() {
|
||||
@Subscribe( threadMode = ThreadMode.MAIN )
|
||||
public void onMarkerInfo( final MarkerInfo event ) {
|
||||
Logger.d( TAG, "onMarkerInfo ------>" );
|
||||
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
|
||||
mogoImageloader.downloadImage( getActivity(), event.imageUrl, new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
Logger.d(TAG, "onMarkerInfo onStart ------>");
|
||||
Logger.d( TAG, "onMarkerInfo onStart ------>" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(Bitmap bitmap) {
|
||||
Logger.d(TAG, "onMarkerInfo onCompleted ------>");
|
||||
public void onCompleted( Bitmap bitmap ) {
|
||||
Logger.d( TAG, "onMarkerInfo onCompleted ------>" );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.icon(mMarkerIcon)
|
||||
.latitude(event.lat)
|
||||
.owner(TanluConstants.MODEL_NAME)
|
||||
.longitude(event.lon);
|
||||
.icon( mMarkerIcon )
|
||||
.latitude( event.lat )
|
||||
.owner( TanluConstants.MODEL_NAME )
|
||||
.longitude( event.lon );
|
||||
|
||||
mMogoMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(getContext());
|
||||
mMarkerManager = mMogoMapService.getMarkerManager(getContext());
|
||||
IMogoMarker marker = mMarkerManager.addMarker(TanluConstants.MODEL_NAME, options);
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||
mMarkerManager = mMogoMapService.getMarkerManager( getContext() );
|
||||
IMogoMarker marker = mMarkerManager.addMarker( TanluConstants.MODEL_NAME, options );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
Logger.e(TAG, "onMarkerInfo onFailure -----e =" + e);
|
||||
public void onFailure( Exception e ) {
|
||||
Logger.e( TAG, "onMarkerInfo onFailure -----e =" + e );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,107 +656,107 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
public void getNavigationLineData() {
|
||||
Double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
|
||||
Double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
|
||||
Logger.e(TAG, "getNavigationLineData lon = " + lon + ">>>>> lat= " + lat);
|
||||
mTanluModelData.getNavigationLineData(lon, lat, new AlongTheWayCallback() {
|
||||
Logger.e( TAG, "getNavigationLineData lon = " + lon + ">>>>> lat= " + lat );
|
||||
mTanluModelData.getNavigationLineData( lon, lat, new AlongTheWayCallback() {
|
||||
@Override
|
||||
public void onSuccess(InformationAndLiveCarResult data) {
|
||||
Logger.d(TAG, "getNavigationLineData onSuccess ");
|
||||
public void onSuccess( InformationAndLiveCarResult data ) {
|
||||
Logger.d( TAG, "getNavigationLineData onSuccess " );
|
||||
//不做任何处理,直接出发推送,重新请求接口,划线
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message, int code) {
|
||||
Logger.e(TAG, "getNavigationLineData onFail message = " + message + ">>>code= " + code);
|
||||
public void onFail( String message, int code ) {
|
||||
Logger.e( TAG, "getNavigationLineData onFail message = " + message + ">>>code= " + code );
|
||||
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 通勤族 事件,监听消息自己请求路线数据
|
||||
*/
|
||||
public void getRoadLineData() {
|
||||
mTanluModelData.getRoadLineData(new RoadLineCallback() {
|
||||
mTanluModelData.getRoadLineData( new RoadLineCallback() {
|
||||
@Override
|
||||
public void onSuccess(PathLineResult o) {
|
||||
public void onSuccess( PathLineResult o ) {
|
||||
//绘制线路线
|
||||
if (o != null && o.getPointList() != null && o.getPointList().size() > 0) {
|
||||
drawMapLine(o.getPointList());
|
||||
if ( o != null && o.getPointList() != null && o.getPointList().size() > 0 ) {
|
||||
drawMapLine( o.getPointList() );
|
||||
} else {
|
||||
Logger.e(TAG, "getRoadLineData onSuccess o.getPointList() == null");
|
||||
Logger.e( TAG, "getRoadLineData onSuccess o.getPointList() == null" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message, int code) {
|
||||
Logger.d(TAG, "getRoadLineData onFail message =" + message + ">>>code =" + code);
|
||||
public void onFail( String message, int code ) {
|
||||
Logger.d( TAG, "getRoadLineData onFail message =" + message + ">>>code =" + code );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航路线,监听消息自己请求路线数据
|
||||
*/
|
||||
public void getNaviRoadLineInfo() {
|
||||
mTanluModelData.getNaviRoadLineInfo(new RoadLineCallback() {
|
||||
mTanluModelData.getNaviRoadLineInfo( new RoadLineCallback() {
|
||||
@Override
|
||||
public void onSuccess(PathLineResult o) {
|
||||
public void onSuccess( PathLineResult o ) {
|
||||
//绘制线路线
|
||||
if (o != null && o.getPointList() != null && o.getPointList().size() > 0) {
|
||||
drawMapLine(o.getPointList());
|
||||
if ( o != null && o.getPointList() != null && o.getPointList().size() > 0 ) {
|
||||
drawMapLine( o.getPointList() );
|
||||
} else {
|
||||
Logger.e(TAG, "getNaviRoadLineInfo onSuccess o.getPointList() == null");
|
||||
Logger.e( TAG, "getNaviRoadLineInfo onSuccess o.getPointList() == null" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message, int code) {
|
||||
Logger.d(TAG, "getNaviRoadLineInfo onFail message =" + message + ">>>code =" + code);
|
||||
public void onFail( String message, int code ) {
|
||||
Logger.d( TAG, "getNaviRoadLineInfo onFail message =" + message + ">>>code =" + code );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制线路
|
||||
*/
|
||||
private void drawMapLine(List<Center> pointList) {
|
||||
int intervalNum = Utils.getIntervalValue(pointList.size());
|
||||
Logger.d(TAG, "drawMapLine intervalNum = $intervalNum -- pointList.size = ${pointList.size}");
|
||||
private void drawMapLine( List< Center > pointList ) {
|
||||
int intervalNum = Utils.getIntervalValue( pointList.size() );
|
||||
Logger.d( TAG, "drawMapLine intervalNum = $intervalNum -- pointList.size = ${pointList.size}" );
|
||||
int listSize = pointList.size();
|
||||
|
||||
//沿途最多15个点
|
||||
for (int i = 0; i < listSize; i += intervalNum) {
|
||||
passedByPoints.add(new MogoLatLng(pointList.get(i).getLat(), (pointList.get(i).getLon())));
|
||||
for ( int i = 0; i < listSize; i += intervalNum ) {
|
||||
passedByPoints.add( new MogoLatLng( pointList.get( i ).getLat(), ( pointList.get( i ).getLon() ) ) );
|
||||
}
|
||||
|
||||
Logger.d(TAG, "drawMapLine passedByPoints.size() ----> " + passedByPoints.size());
|
||||
MogoLatLng startLatLng = new MogoLatLng(pointList.get(0).getLat(), pointList.get(0).getLon());
|
||||
MogoLatLng endLatLng = new MogoLatLng(pointList.get(listSize - 1).getLat(), pointList.get(listSize - 1).getLon());
|
||||
mMarkerManager.addRouteWay(getContext(), startLatLng, endLatLng, passedByPoints);
|
||||
Logger.d( TAG, "drawMapLine passedByPoints.size() ----> " + passedByPoints.size() );
|
||||
MogoLatLng startLatLng = new MogoLatLng( pointList.get( 0 ).getLat(), pointList.get( 0 ).getLon() );
|
||||
MogoLatLng endLatLng = new MogoLatLng( pointList.get( listSize - 1 ).getLat(), pointList.get( listSize - 1 ).getLon() );
|
||||
mMarkerManager.addRouteWay( getContext(), startLatLng, endLatLng, passedByPoints );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 声音控制道路数据
|
||||
*/
|
||||
public void getVoiceControlRoadData(String keywords) {
|
||||
public void getVoiceControlRoadData( String keywords ) {
|
||||
Double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
|
||||
Double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
|
||||
String cityCode = TanluServiceHandler.getLocationClient().getLastKnowLocation().getCityCode();
|
||||
String adCode = TanluServiceHandler.getLocationClient().getLastKnowLocation().getAdCode();
|
||||
Logger.d(TAG, "getVoiceControlRoadData lat =" + lat + ">>>lon =" + lon + ">>>cityCode=" + cityCode + ">>>adCode =" + adCode);
|
||||
mTanluModelData.getVoiceControlRoadData(keywords, cityCode, lon, lat, adCode, new VoiceSearchCallback() {
|
||||
Logger.d( TAG, "getVoiceControlRoadData lat =" + lat + ">>>lon =" + lon + ">>>cityCode=" + cityCode + ">>>adCode =" + adCode );
|
||||
mTanluModelData.getVoiceControlRoadData( keywords, cityCode, lon, lat, adCode, new VoiceSearchCallback() {
|
||||
@Override
|
||||
public void onSuccess(VoiceSearchResult o) {
|
||||
public void onSuccess( VoiceSearchResult o ) {
|
||||
String discription = o.getDescription();
|
||||
Logger.d(TAG, "getVoiceControlRoadData discription = " + discription);
|
||||
if (o.getInformations() != null && o.getInformations().size() > 0) {
|
||||
speakSuccessVoice(o.getInformations(), discription == null ? "" : discription);
|
||||
Logger.d( TAG, "getVoiceControlRoadData discription = " + discription );
|
||||
if ( o.getInformations() != null && o.getInformations().size() > 0 ) {
|
||||
speakSuccessVoice( o.getInformations(), discription == null ? "" : discription );
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(discription)) {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(discription, null);
|
||||
if ( !TextUtils.isEmpty( discription ) ) {
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( discription, null );
|
||||
} else {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice("未找到其他车主分享的路况信息", null);
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( "未找到其他车主分享的路况信息", null );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,70 +768,70 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message, int code) {
|
||||
Logger.e(TAG, "getVoiceControlRoadData onFail message = " + message + ">>>code= " + code);
|
||||
speakFailVoice(searchfaileVoiceStrings[2]);
|
||||
public void onFail( String message, int code ) {
|
||||
Logger.e( TAG, "getVoiceControlRoadData onFail message = " + message + ">>>code= " + code );
|
||||
speakFailVoice( searchfaileVoiceStrings[2] );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
private void speakSuccessVoice(List<Information> informations, String trafficStatus) {
|
||||
switch (informations.size()) {
|
||||
private void speakSuccessVoice( List< Information > informations, String trafficStatus ) {
|
||||
switch ( informations.size() ) {
|
||||
case 0:
|
||||
Logger.d(TAG, "speakSuccessVoice ----> " + random.nextInt(3));
|
||||
speakFailVoice(searchfaileVoiceStrings[random.nextInt(3)]);
|
||||
Logger.d( TAG, "speakSuccessVoice ----> " + random.nextInt( 3 ) );
|
||||
speakFailVoice( searchfaileVoiceStrings[random.nextInt( 3 )] );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
String.format(voiceGetInfoMationTts, "1") + trafficStatus), null);
|
||||
trackVoiceSearch( 1 );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( (
|
||||
String.format( voiceGetInfoMationTts, "1" ) + trafficStatus ), null );
|
||||
|
||||
case 2:
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
trackVoiceSearch( 1 );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( (
|
||||
String.format(
|
||||
voiceGetInfoMationTts,
|
||||
"2"
|
||||
) + trafficStatus), null);
|
||||
) + trafficStatus ), null );
|
||||
|
||||
|
||||
case 3:
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
trackVoiceSearch( 1 );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( (
|
||||
String.format(
|
||||
voiceGetInfoMationTts,
|
||||
"3"
|
||||
) + trafficStatus), null);
|
||||
) + trafficStatus ), null );
|
||||
|
||||
default:
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
trackVoiceSearch( 1 );
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( (
|
||||
String.format(
|
||||
voiceGetInfoMationTts,
|
||||
"多"
|
||||
) + trafficStatus), null);
|
||||
) + trafficStatus ), null );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initStrings() {
|
||||
voiceGetInfoMationTts =
|
||||
getContext().getResources().getString(R.string.voice_get_informations_tts);
|
||||
getContext().getResources().getString( R.string.voice_get_informations_tts );
|
||||
searchingVoiceStrings =
|
||||
getContext().getResources().getStringArray(R.array.searching_voice_string_array);
|
||||
getContext().getResources().getStringArray( R.array.searching_voice_string_array );
|
||||
searchfaileVoiceStrings =
|
||||
getContext().getResources().getStringArray(R.array.search_fail_voice_array);
|
||||
getContext().getResources().getStringArray( R.array.search_fail_voice_array );
|
||||
}
|
||||
|
||||
private void speakFailVoice(String string) {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(string, null);
|
||||
private void speakFailVoice( String string ) {
|
||||
AIAssist.getInstance( getContext() ).speakTTSVoice( string, null );
|
||||
}
|
||||
|
||||
//上报语音搜索
|
||||
private void trackVoiceSearch(int type) {
|
||||
private void trackVoiceSearch( int type ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,16 @@ public class MogoServicePaths {
|
||||
|
||||
/**
|
||||
* 免唤醒语音控制
|
||||
*
|
||||
* @deprecated use {@link #PATH_INTENT_MANAGER} instead.
|
||||
*/
|
||||
public static final String PATH_VOICE_MANAGER = "/voicemanager/api";
|
||||
|
||||
/**
|
||||
* 意图控制接口
|
||||
*/
|
||||
public static final String PATH_INTENT_MANAGER = "/intentmanager/api";
|
||||
|
||||
/**
|
||||
* 基础功能监听回调注册
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,13 @@ public interface IMogoFragmentManager extends IProvider {
|
||||
*/
|
||||
void pop();
|
||||
|
||||
/**
|
||||
* 栈大小
|
||||
*
|
||||
* @return 栈内的 fragment 数量
|
||||
*/
|
||||
int getStackSize();
|
||||
|
||||
/**
|
||||
* 退出栈中所有fragment
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.service.intent;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 免唤醒语音监听
|
||||
*/
|
||||
public interface IMogoIntentListener {
|
||||
|
||||
/**
|
||||
* @param intentStr 广播action、语音 command
|
||||
* @param intent 意图
|
||||
*/
|
||||
void onIntentReceived( String intentStr, Intent intent );
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.service.intent;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 免唤醒语音控制
|
||||
*/
|
||||
public interface IMogoIntentManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 注册意图接收者
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
public void registerIntentListener( String intent, IMogoIntentListener listener );
|
||||
|
||||
/**
|
||||
* 注册意图接收者
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
public void unregisterIntentListener( String intent );
|
||||
|
||||
/**
|
||||
* 触发意图回调,各业务不用关心
|
||||
*
|
||||
* @param intentStr
|
||||
* @param intent
|
||||
*/
|
||||
public void invoke( String intentStr, Intent intent );
|
||||
}
|
||||
@@ -2,19 +2,15 @@ package com.mogo.service.voice;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 免唤醒语音监听
|
||||
* use {@link IMogoIntentListener} instead.
|
||||
*/
|
||||
public interface IMogoVoiceListener {
|
||||
|
||||
/**
|
||||
* 回调语音意图
|
||||
*
|
||||
* @param command 广播 command
|
||||
* @param intent 意图
|
||||
*/
|
||||
void onIntentReceived( String command, Intent intent );
|
||||
@Deprecated
|
||||
public interface IMogoVoiceListener extends IMogoIntentListener {
|
||||
}
|
||||
|
||||
@@ -2,35 +2,17 @@ package com.mogo.service.voice;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 免唤醒语音控制
|
||||
* <p>
|
||||
* use {@link IMogoIntentManager} instead.
|
||||
*/
|
||||
public interface IMogoVoiceManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 注册意图接收者
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
void registerIntentListener( String command, IMogoVoiceListener listener );
|
||||
|
||||
/**
|
||||
* 注册意图接收者
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
void unregisterIntentListener( String command );
|
||||
|
||||
/**
|
||||
* 触发意图回调,各业务不用关心
|
||||
*
|
||||
* @param command
|
||||
* @param intent
|
||||
*/
|
||||
void invoke( String command, Intent intent );
|
||||
@Deprecated
|
||||
public interface IMogoVoiceManager extends IMogoIntentManager {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.service.impl.voice;
|
||||
package com.mogo.service.impl.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -8,11 +8,10 @@ import android.os.Message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -23,9 +22,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class VoiceManager implements IMogoVoiceManager {
|
||||
public class IntentManager implements IMogoIntentManager {
|
||||
|
||||
private static volatile VoiceManager sInstance;
|
||||
private static volatile IntentManager sInstance;
|
||||
|
||||
public static final int MSG_COMMAND_RECEIVED = 2000;
|
||||
|
||||
@@ -36,9 +35,9 @@ public class VoiceManager implements IMogoVoiceManager {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_COMMAND_RECEIVED ) {
|
||||
MsgObject object = ( ( MsgObject ) msg.obj );
|
||||
List< IMogoVoiceListener > listeners = mListeners.get( object.getCommand() );
|
||||
List< IMogoIntentListener > listeners = mListeners.get( object.getCommand() );
|
||||
if ( listeners != null && !listeners.isEmpty() ) {
|
||||
for ( IMogoVoiceListener listener : listeners ) {
|
||||
for ( IMogoIntentListener listener : listeners ) {
|
||||
listener.onIntentReceived( object.getCommand(), object.getIntent() );
|
||||
}
|
||||
}
|
||||
@@ -46,14 +45,14 @@ public class VoiceManager implements IMogoVoiceManager {
|
||||
}
|
||||
};
|
||||
|
||||
private VoiceManager() {
|
||||
private IntentManager() {
|
||||
}
|
||||
|
||||
public static VoiceManager getInstance() {
|
||||
public static IntentManager getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( VoiceManager.class ) {
|
||||
synchronized ( IntentManager.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new VoiceManager();
|
||||
sInstance = new IntentManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,18 +64,17 @@ public class VoiceManager implements IMogoVoiceManager {
|
||||
}
|
||||
|
||||
|
||||
private Map< String, List< IMogoVoiceListener > > mListeners = new ConcurrentHashMap<>();
|
||||
private Map< String, List< IMogoIntentListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String command, IMogoVoiceListener listener ) {
|
||||
if ( listener == null || command == null ) {
|
||||
public void registerIntentListener( String intent, IMogoIntentListener listener ) {
|
||||
if ( listener == null || intent == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( command ) ) {
|
||||
mListeners.put( command, new ArrayList<>() );
|
||||
if ( !mListeners.containsKey( intent ) ) {
|
||||
mListeners.put( intent, new ArrayList<>() );
|
||||
}
|
||||
mListeners.get( command ).add( listener );
|
||||
|
||||
mListeners.get( intent ).add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.service.impl.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_INTENT_MANAGER )
|
||||
public class MogoIntentManager implements IMogoIntentManager {
|
||||
|
||||
@Override
|
||||
public void unregisterIntentListener( String command ) {
|
||||
IntentManager.getInstance().unregisterIntentListener( command );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String command, Intent intent ) {
|
||||
IntentManager.getInstance().invoke( command, intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String intent, IMogoIntentListener listener ) {
|
||||
IntentManager.getInstance().registerIntentListener( intent, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
IntentManager.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.mogo.service.impl.voice;
|
||||
package com.mogo.service.impl.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.voice.IMogoVoiceListener;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.voice.IMogoVoiceManager;
|
||||
import com.zhidao.auto.platform.voice.VoiceClient;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -20,23 +18,23 @@ import com.zhidao.auto.platform.voice.VoiceClient;
|
||||
@Route( path = MogoServicePaths.PATH_VOICE_MANAGER )
|
||||
public class MogoVoiceManager implements IMogoVoiceManager {
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String command, IMogoVoiceListener listener ) {
|
||||
VoiceManager.getInstance().registerIntentListener( command, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterIntentListener( String command ) {
|
||||
VoiceManager.getInstance().unregisterIntentListener( command );
|
||||
IntentManager.getInstance().unregisterIntentListener( command );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke( String command, Intent intent ) {
|
||||
VoiceManager.getInstance().invoke( command, intent );
|
||||
IntentManager.getInstance().invoke( command, intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String intent, IMogoIntentListener listener ) {
|
||||
IntentManager.getInstance().registerIntentListener( intent, listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
VoiceManager.getInstance().init( context );
|
||||
IntentManager.getInstance().init( context );
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.service.impl.voice;
|
||||
package com.mogo.service.impl.intent;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
Reference in New Issue
Block a user