opt
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user