合并黑夜白天模式等需求
This commit is contained in:
@@ -30,6 +30,7 @@ import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
@@ -224,9 +225,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 手动刷新回调
|
||||
*/
|
||||
private RefreshCallback mCustomRefreshCallback = new RefreshCallback() {
|
||||
private RefreshCallback mCustomRefreshCallback = new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( Object o ) {
|
||||
public void onSuccess( MarkerResponse o ) {
|
||||
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
|
||||
mLoopRequest = false;
|
||||
// 用户手动操作地图刷新成功后,设置状态为 true,引发延时策略
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, true );
|
||||
@@ -241,9 +243,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 自动刷新回调
|
||||
*/
|
||||
private RefreshCallback mAutoRefreshCallback = new RefreshCallback() {
|
||||
private RefreshCallback mAutoRefreshCallback = new RefreshCallback<MarkerResponse>() {
|
||||
@Override
|
||||
public void onSuccess( Object o ) {
|
||||
public void onSuccess( MarkerResponse o ) {
|
||||
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
|
||||
mLoopRequest = false;
|
||||
Logger.d( TAG, "request Success." );
|
||||
invokeAutoRefreshStrategy();
|
||||
@@ -269,7 +272,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 当前限速
|
||||
*/
|
||||
private int mCurrentLimit = 0;
|
||||
private int mCurrentLimit = -1;
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
@@ -436,7 +439,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
mRefreshModel.refreshData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
|
||||
|
||||
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );
|
||||
@@ -481,6 +484,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
|
||||
filter.addAction( MogoReceiver.ACTION_MOGO );
|
||||
filter.addAction(MogoReceiver.ACTION_TXZ_BLOCK_SEARCH);
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
Logger.i( TAG, "register voice receiver." );
|
||||
@@ -817,7 +821,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( mCurrentLimit == traffic.getSpeedLimit() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,6 +335,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
case 17:
|
||||
DebugConfig.setRequestOnlineCarData( intent.getBooleanExtra( "status", true ) );
|
||||
break;
|
||||
case 30:
|
||||
MarkerServiceHandler.getMapService().getMapUIController().forceRender();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ public class LauncherCardRefreshStrategy {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void next(){
|
||||
getType();
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return type.limit;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.VoicePreemptType;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
@@ -16,10 +18,23 @@ import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.network.ZhidaoRefreshModel;
|
||||
import com.mogo.module.service.network.bean.LauncherCardAdvertisementData;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -37,13 +52,39 @@ class LauncherCardRefresher {
|
||||
|
||||
private static volatile LauncherCardRefresher sInstance;
|
||||
|
||||
public static final int MSG_REFRESH = 2020;
|
||||
public static final int MSG_TTS_TIP = 2021;
|
||||
public static final long ONE_MINUTE = 15 * 1000L;
|
||||
// 刷新道路事件/车友
|
||||
public static final int MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA = 2020;
|
||||
// 开始引导策略
|
||||
public static final int MSG_INDUCE = 2019;
|
||||
// 刷新卡片默认显示内容
|
||||
public static final int MSG_REFRESH_DEFAULT_CARD = 2021;
|
||||
// 刷新卡片广告
|
||||
public static final int MSG_REFRESH_ADVERTISEMENT = 2022;
|
||||
// 加载网络配置数据
|
||||
public static final int MSG_LOAD_NET_CONFIG = 2023;
|
||||
// 默认播报
|
||||
public static final int MSG_START_LOOP_DEFAULT_CARD = 2024;
|
||||
public static final long ONE_MINUTE = 60 * 1000L;
|
||||
public static final long ONE_DAY = 24 * 60 * ONE_MINUTE;
|
||||
private String mLaunchTTSText;
|
||||
private long mDefaultTTSPlayInterval = 30 * ONE_MINUTE;
|
||||
private LauncherCardAdvertisementData.LauncherCardAdvertisement mDefaultLauncherCardConfig;
|
||||
private List< LauncherCardAdvertisementData.LauncherCardAdvertisement > mAdvertisements;
|
||||
|
||||
/**
|
||||
* 默认播报/后台配置播报次数限制
|
||||
*/
|
||||
private int mDefaultConfigCounter = 0;
|
||||
|
||||
/**
|
||||
* 因为缓存ticket失效导致失败的情况,需要重新请求ticket然后再次获取数据,这里重试3次
|
||||
*/
|
||||
private int mRefreshTicketCounter = 0;
|
||||
|
||||
private LauncherCardRefresher( Context context ) {
|
||||
mContext = context;
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
mZhidaoRefreshModel = new ZhidaoRefreshModel( mContext );
|
||||
}
|
||||
|
||||
public static LauncherCardRefresher getInstance( Context context ) {
|
||||
@@ -74,17 +115,30 @@ class LauncherCardRefresher {
|
||||
return;
|
||||
}
|
||||
switch ( msg.what ) {
|
||||
case MSG_REFRESH:
|
||||
case MSG_LOAD_NET_CONFIG:
|
||||
loadNetworkConfigStrategy();
|
||||
break;
|
||||
case MSG_REFRESH_DEFAULT_CARD:
|
||||
renderDefaultLauncherCardConfig( false );
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
break;
|
||||
case MSG_INDUCE:
|
||||
handleInduceStrategy();
|
||||
break;
|
||||
case MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA:
|
||||
try {
|
||||
handleRefreshMsg();
|
||||
handleRefreshExplorerWayOrOnlineCarMsg();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error when refresh launcher card." );
|
||||
}
|
||||
break;
|
||||
case MSG_TTS_TIP:
|
||||
playTTS();
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
case MSG_START_LOOP_DEFAULT_CARD:
|
||||
renderDefaultLauncherCardConfig( false );
|
||||
break;
|
||||
case MSG_REFRESH_ADVERTISEMENT:
|
||||
int index = msg.arg1;// 当前广告索引
|
||||
loopRenderAdvertisements( index );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,17 +148,18 @@ class LauncherCardRefresher {
|
||||
private boolean mRefreshStop = true;
|
||||
private boolean mStart = false;
|
||||
private RefreshModel mRefreshModel;
|
||||
private LauncherCardRefreshStrategy mRefreshStrategy = new LauncherCardRefreshStrategy(
|
||||
2 * ONE_MINUTE,
|
||||
new LauncherCardRefreshStrategy(
|
||||
3 * ONE_MINUTE,
|
||||
new LauncherCardRefreshStrategy(
|
||||
20 * ONE_MINUTE,
|
||||
null,
|
||||
MSG_REFRESH ),
|
||||
MSG_REFRESH ),
|
||||
MSG_TTS_TIP
|
||||
private ZhidaoRefreshModel mZhidaoRefreshModel;
|
||||
|
||||
private LauncherCardRefreshStrategy mExplorerWayOrOnlineCarDataStrategy = new LauncherCardRefreshStrategy(
|
||||
20 * ONE_MINUTE,null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
|
||||
);
|
||||
private LauncherCardRefreshStrategy mInduceStrategy = new LauncherCardRefreshStrategy(
|
||||
3 * ONE_MINUTE,mExplorerWayOrOnlineCarDataStrategy, MSG_INDUCE
|
||||
);
|
||||
private LauncherCardRefreshStrategy mLauncherCardConfigStrategy = new LauncherCardRefreshStrategy(
|
||||
2 * ONE_MINUTE,mInduceStrategy, MSG_REFRESH_DEFAULT_CARD
|
||||
);
|
||||
private LauncherCardRefreshStrategy mRefreshStrategy = mLauncherCardConfigStrategy;
|
||||
|
||||
public void start() {
|
||||
if ( DebugConfig.isLauncher() || DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
|
||||
@@ -113,33 +168,38 @@ class LauncherCardRefresher {
|
||||
if ( mStart ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int counter = SharedPrefsMgr.getInstance( mContext ).getInt( KEY_LauncherCardTipCounter, 0 );
|
||||
if ( counter >= 5 ) {
|
||||
long lastTipTime = SharedPrefsMgr.getInstance( mContext ).getLong( KEY_LauncherCardTipLastTipTime, 0L );
|
||||
if ( System.currentTimeMillis() - lastTipTime < 10 * ONE_DAY ) {
|
||||
stop();
|
||||
return;
|
||||
} else {
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, 0 );
|
||||
counter = 0;
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, 0L );
|
||||
}
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
Logger.d( TAG, "start" );
|
||||
mLaunchTTSText = mContext.getString( R.string.module_service_open_app_tip );
|
||||
mDefaultConfigCounter = 0;
|
||||
mRefreshTicketCounter = 0;
|
||||
mRefreshStrategy = mLauncherCardConfigStrategy;
|
||||
// 延时加载数据,已保证accOn之后网络恢复正常
|
||||
long delay = ONE_MINUTE;
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
delay = 0L;
|
||||
}
|
||||
mHandler.sendEmptyMessageDelayed( MSG_LOAD_NET_CONFIG, delay );
|
||||
startInduceStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 引导策略:本地策略 & 网络策略
|
||||
*/
|
||||
private void startInduceStrategy() {
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
mRefreshStop = false;
|
||||
mStart = true;
|
||||
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, ++counter );
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mRefreshStop = true;
|
||||
mStart = false;
|
||||
mHandler.removeMessages( MSG_REFRESH );
|
||||
mHandler.removeMessages( MSG_TTS_TIP );
|
||||
mHandler.removeMessages( MSG_INDUCE );
|
||||
mHandler.removeMessages( MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA );
|
||||
mHandler.removeMessages( MSG_REFRESH_DEFAULT_CARD );
|
||||
mHandler.removeMessages( MSG_START_LOOP_DEFAULT_CARD );
|
||||
mHandler.removeMessages( MSG_REFRESH_ADVERTISEMENT );
|
||||
mHandler.removeMessages( MSG_LOAD_NET_CONFIG );
|
||||
Logger.d( TAG, "stop" );
|
||||
}
|
||||
|
||||
@@ -148,104 +208,112 @@ class LauncherCardRefresher {
|
||||
return;
|
||||
}
|
||||
mRefreshStop = false;
|
||||
mHandler.removeMessages( MSG_REFRESH );
|
||||
mHandler.removeMessages( MSG_TTS_TIP );
|
||||
mHandler.removeMessages( mRefreshStrategy.getMsgType() );
|
||||
mHandler.sendEmptyMessageDelayed( mRefreshStrategy.getMsgType(), mRefreshStrategy.getInterval() );
|
||||
}
|
||||
|
||||
private void handleRefreshMsg() {
|
||||
if ( mRefreshModel == null ) {
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
/**
|
||||
* 开始诱导策略
|
||||
* 第一次如果有活动,则优先播报活动,否则播报道路事件/车友
|
||||
* 后面的按各自的时间间隔播报
|
||||
*/
|
||||
private void handleInduceStrategy() {
|
||||
if ( mAdvertisements != null && !mAdvertisements.isEmpty() ) {
|
||||
loopRenderAdvertisements( 0 );
|
||||
startNextRefreshStrategy();
|
||||
} else {
|
||||
handleRefreshExplorerWayOrOnlineCarMsg();
|
||||
}
|
||||
}
|
||||
|
||||
private void startNextRefreshStrategy() {
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
|
||||
private void handleRefreshExplorerWayOrOnlineCarMsg() {
|
||||
MogoLocation location = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
|
||||
if ( location == null ) {
|
||||
restart();
|
||||
return;
|
||||
}
|
||||
MogoLatLng latLng = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
if ( mRefreshStrategy.getType() == LauncherCardRefreshType.ExploreWay ) {
|
||||
handleRefreshExplorerWayData( latLng );
|
||||
} else {
|
||||
handleRefreshOnlineCarData( latLng );
|
||||
}
|
||||
handleRefreshExplorerWayOrOnlineCarData( latLng, mRefreshStrategy.getType() );
|
||||
}
|
||||
|
||||
private void handleRefreshExplorerWayData( MogoLatLng latLng ) {
|
||||
private void handleRefreshExplorerWayOrOnlineCarData( MogoLatLng latLng, LauncherCardRefreshType type ) {
|
||||
mRefreshModel.refreshDataSync( latLng,
|
||||
mRefreshStrategy.getRadius(),
|
||||
mRefreshStrategy.getLimit(),
|
||||
new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse response ) {
|
||||
notifyLauncherCard( LauncherCardRefreshType.ExploreWay, response );
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
notifyRefreshChanged( type, response );
|
||||
startNextRefreshStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void handleRefreshOnlineCarData( MogoLatLng latLng ) {
|
||||
mRefreshModel.queryOnLineCarWithRoute( latLng,
|
||||
false,
|
||||
true,
|
||||
mRefreshStrategy.getRadius(),
|
||||
mRefreshStrategy.getLimit(),
|
||||
new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse response ) {
|
||||
notifyLauncherCard( LauncherCardRefreshType.OnlineCar, response );
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
mRefreshStrategy = mRefreshStrategy.getNext();
|
||||
restart();
|
||||
startNextRefreshStrategy();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
private boolean notifyLauncherCard( LauncherCardRefreshType type, MarkerResponse response ) {
|
||||
private boolean notifyRefreshChanged( LauncherCardRefreshType type, MarkerResponse response ) {
|
||||
if ( response == null || response.getResult() == null ) {
|
||||
return false;
|
||||
}
|
||||
String tts = mContext.getString( R.string.module_service_launcher_card_tips );
|
||||
String info = mContext.getString( R.string.module_service_launcher_card_info );
|
||||
|
||||
LauncherCardRefreshType target = null;
|
||||
int size = 0;
|
||||
if ( type == LauncherCardRefreshType.ExploreWay ) {
|
||||
if ( response.getResult().getExploreWay() == null || response.getResult().getExploreWay().isEmpty() ) {
|
||||
return false;
|
||||
if ( response.getResult().getExploreWay() != null && !response.getResult().getExploreWay().isEmpty() ) {
|
||||
target = type;
|
||||
size = response.getResult().getExploreWay().size();
|
||||
} else if ( response.getResult().getOnlineCar() != null && !response.getResult().getOnlineCar().isEmpty() ) {
|
||||
target = LauncherCardRefreshType.OnlineCar;
|
||||
size = response.getResult().getOnlineCar().size();
|
||||
}
|
||||
int size = response.getResult().getExploreWay().size();
|
||||
speakTTS( tts = String.format( tts, size, mRefreshStrategy.getDesc() ) );
|
||||
notifyLauncherCard( String.format( info, size, mRefreshStrategy.getDesc() ), size, tts );
|
||||
} else {
|
||||
if ( response.getResult().getOnlineCar() == null || response.getResult().getOnlineCar().isEmpty() ) {
|
||||
return false;
|
||||
} else if ( type == LauncherCardRefreshType.OnlineCar ) {
|
||||
if ( response.getResult().getOnlineCar() != null && !response.getResult().getOnlineCar().isEmpty() ) {
|
||||
target = type;
|
||||
size = response.getResult().getOnlineCar().size();
|
||||
} else if ( response.getResult().getExploreWay() != null && !response.getResult().getExploreWay().isEmpty() ) {
|
||||
target = LauncherCardRefreshType.ExploreWay;
|
||||
size = response.getResult().getExploreWay().size();
|
||||
}
|
||||
int size = response.getResult().getOnlineCar().size();
|
||||
speakTTS( tts = String.format( tts, size, mRefreshStrategy.getDesc() ) );
|
||||
notifyLauncherCard( String.format( info, size, mRefreshStrategy.getDesc() ), size , tts);
|
||||
}
|
||||
|
||||
Logger.d( TAG, "返回数据情况:道路事件:%s, 车友: %s", response.getResult().getExploreWay() == null ? 0 : response.getResult().getExploreWay().size(),
|
||||
response.getResult().getOnlineCar() == null ? 0 : response.getResult().getOnlineCar().size() );
|
||||
|
||||
if ( size == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( target != type ) {
|
||||
mRefreshStrategy.next();// 本次请求到的数据类型和播报类型不一致,则下次再次请求本次类型~
|
||||
}
|
||||
|
||||
speakTTS( tts = String.format( tts, size, target.desc ), true );
|
||||
notifyRefreshChanged( String.format( info, size, target.desc ), size, tts );
|
||||
return true;
|
||||
}
|
||||
|
||||
private void speakTTS( String msg ) {
|
||||
if ( AppUtils.isAppForeground( mContext ) ) {
|
||||
return;
|
||||
private void speakTTS( String msg, boolean checkAppForeground ) {
|
||||
if ( checkAppForeground ) {
|
||||
if ( AppUtils.isAppForeground( mContext ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Logger.d( TAG, msg );
|
||||
AIAssist.getInstance( mContext ).speakTTSVoice( msg );
|
||||
}
|
||||
|
||||
private void notifyLauncherCard( String info, int amount, String tts ) {
|
||||
private void notifyRefreshChanged( String info, int amount, String tts ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.v2x" );
|
||||
intent.putExtra( "v2x_warning_type", "20000" );
|
||||
intent.putExtra( "v2x_warining_timeout", 20 * 1000 );
|
||||
@@ -256,11 +324,211 @@ class LauncherCardRefresher {
|
||||
Logger.d( TAG, "发送广播到桌面卡片." );
|
||||
}
|
||||
|
||||
private void playTTS() {
|
||||
/**
|
||||
* 1. 刷新默认卡片样式
|
||||
* <p>
|
||||
* 2. 播报默认卡片语音
|
||||
*
|
||||
* @param sendConfigOnly 仅发送配置到
|
||||
*/
|
||||
private void renderDefaultLauncherCardConfig( boolean sendConfigOnly ) {
|
||||
if ( mDefaultLauncherCardConfig != null ) {
|
||||
long curr = System.currentTimeMillis();
|
||||
if ( mDefaultLauncherCardConfig.endTime > curr && mDefaultLauncherCardConfig.startTime < curr ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.v2x.card" );
|
||||
intent.putExtra( "v2x_card_title", mDefaultLauncherCardConfig.name );
|
||||
intent.putExtra( "v2x_card_icon", mDefaultLauncherCardConfig.filePath );
|
||||
intent.putExtra( "v2x_card_content", mDefaultLauncherCardConfig.cardContent );
|
||||
intent.putExtra( "v2x_card_button_name", mDefaultLauncherCardConfig.buttonContent );
|
||||
intent.putExtra( "v2x_card_startTime", mDefaultLauncherCardConfig.startTime );
|
||||
intent.putExtra( "v2x_card_endTime", mDefaultLauncherCardConfig.endTime );
|
||||
intent.putExtra( "v2x_card_is_default", true );
|
||||
mContext.sendBroadcast( intent );
|
||||
Logger.d( TAG, "发送默认配置广播到桌面卡片." );
|
||||
if ( !TextUtils.isEmpty( mDefaultLauncherCardConfig.content ) ) {
|
||||
mLaunchTTSText = mDefaultLauncherCardConfig.content;
|
||||
}
|
||||
if ( mDefaultLauncherCardConfig.popupNum > 0 ) {
|
||||
mDefaultTTSPlayInterval = mDefaultLauncherCardConfig.popupNum * ONE_MINUTE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sendConfigOnly ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mDefaultConfigCounter++ >= 3 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int counter = SharedPrefsMgr.getInstance( mContext ).getInt( KEY_LauncherCardTipCounter, 0 );
|
||||
if ( counter >= 5 ) {
|
||||
long lastTipTime = SharedPrefsMgr.getInstance( mContext ).getLong( KEY_LauncherCardTipLastTipTime, 0L );
|
||||
if ( System.currentTimeMillis() - lastTipTime < 10 * ONE_DAY ) {
|
||||
return;
|
||||
} else {
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, 0 );
|
||||
counter = 0;
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, 0L );
|
||||
}
|
||||
}
|
||||
SharedPrefsMgr.getInstance( mContext ).putInt( KEY_LauncherCardTipCounter, ++counter );
|
||||
SharedPrefsMgr.getInstance( mContext ).putLong( KEY_LauncherCardTipLastTipTime, System.currentTimeMillis() );
|
||||
|
||||
try {
|
||||
AIAssist.getInstance( mContext ).speakTTSVoice( mContext.getString( R.string.module_service_open_app_tip ) );
|
||||
speakTTS( mLaunchTTSText, true );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
startLoopDefaultConfigStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求广告数据
|
||||
*/
|
||||
private void loadNetworkConfigStrategy() {
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext )
|
||||
.append( "modelType", 30 )
|
||||
.build();
|
||||
mZhidaoRefreshModel.getRefreshApiService().getCarAdvertisingList( query )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< LauncherCardAdvertisementData >( RequestOptions.create( mContext ) ) {
|
||||
@Override
|
||||
public void onError( Throwable e ) {
|
||||
super.onError( e );
|
||||
Logger.e( TAG, e, "获取配置失败" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess( LauncherCardAdvertisementData data ) {
|
||||
super.onSuccess( data );
|
||||
if ( data == null || data.result == null ) {
|
||||
Logger.d( TAG, "carAdvertisingList is empty." );
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "获取配置成功" );
|
||||
handleGotCarAdvertisingList( data.result );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
if ( code == 100046 ) {
|
||||
refreshTicket();
|
||||
}
|
||||
Logger.e( TAG, "获取配置失败 msg = %s, code = %s", message, code );
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
private void refreshTicket() {
|
||||
mRefreshTicketCounter++;
|
||||
Logger.d( TAG, "刷新ticket" );
|
||||
MarkerServiceHandler.getApis().getPassportManagerApi().requestTicket( new IMogoTicketCallback() {
|
||||
@Override
|
||||
public void onTicketGot( String ticket ) {
|
||||
Logger.d( TAG, "ticket=%s", ticket );
|
||||
if ( mRefreshTicketCounter < 3 ) {
|
||||
loadNetworkConfigStrategy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( int code, String msg ) {
|
||||
Logger.d( TAG, "code=%s, msg=%s", code, msg );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginSuccess( String token, String sn ) {
|
||||
Logger.d( TAG, "token=%s, sn=%s", token, sn );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void handleGotCarAdvertisingList( List< LauncherCardAdvertisementData.LauncherCardAdvertisement > data ) {
|
||||
if ( data == null ) {
|
||||
mAdvertisements = null;
|
||||
return;
|
||||
}
|
||||
|
||||
mAdvertisements = new ArrayList<>();
|
||||
for ( LauncherCardAdvertisementData.LauncherCardAdvertisement launcherCardAdvertisement : data ) {
|
||||
if ( launcherCardAdvertisement == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( launcherCardAdvertisement.cardType == LauncherCardAdvertisementData.TYPE_DEFAULT_CONFIG ) {
|
||||
mDefaultLauncherCardConfig = launcherCardAdvertisement;
|
||||
renderDefaultLauncherCardConfig( true );
|
||||
} else if ( launcherCardAdvertisement.cardType == LauncherCardAdvertisementData.TYPE_ACTIVITY ) {
|
||||
long curr = System.currentTimeMillis();
|
||||
if ( curr > launcherCardAdvertisement.startTime && curr < launcherCardAdvertisement.endTime ) {
|
||||
mAdvertisements.add( launcherCardAdvertisement );
|
||||
} else {
|
||||
Logger.w( TAG, "广告已过期 %s", launcherCardAdvertisement.cardContent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mAdvertisements.isEmpty() && mAdvertisements.size() > 1 ) {
|
||||
LauncherCardAdvertisementData.LauncherCardAdvertisement[] sorted = new LauncherCardAdvertisementData.LauncherCardAdvertisement[mAdvertisements.size()];
|
||||
sorted = mAdvertisements.toArray( sorted );
|
||||
Arrays.sort( sorted, ( ( o1, o2 ) -> {
|
||||
return o1.sort > o2.sort ? 1 : ( o1.sort == o2.sort ? 0 : -1 );
|
||||
} ) );
|
||||
mAdvertisements = Arrays.asList( sorted );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认播报 / 后台配置默认项播报策略
|
||||
*/
|
||||
private void startLoopDefaultConfigStrategy() {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_START_LOOP_DEFAULT_CARD;
|
||||
mHandler.sendMessageDelayed( msg, mDefaultTTSPlayInterval );
|
||||
}
|
||||
|
||||
private void loopRenderAdvertisements( int index ) {
|
||||
try {
|
||||
index = index % mAdvertisements.size();
|
||||
LauncherCardAdvertisementData.LauncherCardAdvertisement advertisement = mAdvertisements.get( index );
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_REFRESH_ADVERTISEMENT;
|
||||
msg.arg1 = ++index;
|
||||
mHandler.sendMessageDelayed( msg, advertisement.popupNum * ONE_MINUTE );
|
||||
renderAdvertisement( advertisement );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "loopRenderAdvertisements" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新广告
|
||||
*/
|
||||
private void renderAdvertisement( LauncherCardAdvertisementData.LauncherCardAdvertisement advertisement ) {
|
||||
if ( advertisement == null ) {
|
||||
return;
|
||||
}
|
||||
long curr = System.currentTimeMillis();
|
||||
if ( advertisement.endTime > curr && advertisement.startTime < curr ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.v2x.card" );
|
||||
intent.putExtra( "v2x_card_title", advertisement.name );
|
||||
intent.putExtra( "v2x_card_icon", advertisement.filePath );
|
||||
intent.putExtra( "v2x_card_content", advertisement.cardContent );
|
||||
intent.putExtra( "v2x_card_button_name", advertisement.buttonContent );
|
||||
intent.putExtra( "v2x_card_startTime", advertisement.startTime );
|
||||
intent.putExtra( "v2x_card_endTime", advertisement.endTime );
|
||||
intent.putExtra( "v2x_card_activity_id", advertisement.id );
|
||||
intent.putExtra( "v2x_card_timeout", 20 * 1000 );
|
||||
intent.putExtra( "v2x_card_is_default", false );
|
||||
mContext.sendBroadcast( intent );
|
||||
if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
speakTTS( advertisement.content, true );
|
||||
}
|
||||
Logger.d( TAG, "发送广告配置广播到桌面卡片." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,12 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerNoveltyInfo;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -56,7 +52,7 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
|
||||
}
|
||||
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.view_map_marker_info, this );
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout_info, this );
|
||||
ivUserHead = findViewById( R.id.ivUserHead );
|
||||
ivIcon = findViewById( R.id.ivIcon );
|
||||
clMarkerContent = findViewById( R.id.clMarkerContent );
|
||||
@@ -94,10 +90,10 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_refuel );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_check2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_check2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_off2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_off2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop_discount );
|
||||
@@ -106,43 +102,43 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_4s );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ROAD_WORK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_work2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_work2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_BLOCK_UP:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PONDING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_pondingl2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_pondingl2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP_FREE:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_FOG:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_dark_frog2_light );
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_dark_frog2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ICE:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_freeze2_light );
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_freeze2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PARKING:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_parking2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ACCIDENT:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_accident3_light );
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_accident3_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_NEALY:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shear_news );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_living_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_living_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ILLEGAL_PARK_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_illegal_park_light );
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_illegal_park_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_SLIPPERY:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_road_slippery_light );
|
||||
break;
|
||||
default:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_light );
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_white );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.entity.MarkerCarPois;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
@@ -32,8 +33,10 @@ import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
@@ -58,7 +61,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
IMogoOnMessageListener< MarkerResponse >,
|
||||
IMogoBizActionDoneListener {
|
||||
IMogoBizActionDoneListener,
|
||||
IMogoADASControlStatusChangedListener {
|
||||
private static final String TAG = "MapMarkerManager";
|
||||
|
||||
private Context mContext;
|
||||
@@ -105,9 +109,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mContext = context.getApplicationContext();
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
|
||||
// 长连接
|
||||
MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
|
||||
// 长连接 - 长链变短链
|
||||
// MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
|
||||
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
|
||||
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener( TAG, this );
|
||||
}
|
||||
|
||||
// ACC ON 的时候重置为true,ACC OFF 设置为 false
|
||||
@@ -668,7 +673,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
try {
|
||||
return drawMapMarkerImpl( markerShowEntity, zIndex );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
Logger.e( TAG, e, "drawMapMarker" );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -715,6 +720,16 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
} );
|
||||
}
|
||||
|
||||
public void onSyncMarkerResponse( MarkerResponse response ) {
|
||||
if ( ignoreDrawRequest() ) {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "接收到了地图大而全数据" );
|
||||
runOnTargetThread( () -> {
|
||||
drawMapMarker( response );
|
||||
} );
|
||||
}
|
||||
|
||||
public void syncLocation( double lon, double lat ) {
|
||||
mCarLatLng = new MogoLatLng( lat, lon );
|
||||
}
|
||||
@@ -864,6 +879,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
// 平滑移动
|
||||
private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
|
||||
MarkerLocation markerLocation ) {
|
||||
if ( iMogoMarker == null ) {
|
||||
return;
|
||||
}
|
||||
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
|
||||
if ( filterErrorPoint( poiList ) ) {
|
||||
return;
|
||||
@@ -966,4 +984,21 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapUiModeChanged( EnumMapUI mapUI ) {
|
||||
switch ( mapUI ) {
|
||||
case Type_Light:
|
||||
case Type_Night:
|
||||
if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
return;
|
||||
}
|
||||
if ( mLastDataResult != null ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
drawMarkerByCurrentType( mLastDataResult );
|
||||
mLastCheckMarker = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mogo.module.service.marker;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -43,7 +42,7 @@ public class MapMarkerView extends MapMarkerBaseView {
|
||||
}
|
||||
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.view_map_marker, this );
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout, this );
|
||||
ivIcon = findViewById( R.id.ivIcon );
|
||||
ivCar = findViewById( R.id.ivCar );
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
@@ -22,7 +21,6 @@ import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.network.RefreshApiService;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.network.bean.DemoUserInfoEntity;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
@@ -92,7 +90,7 @@ public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||
}
|
||||
|
||||
if ( mInfoWindowView == null ) {
|
||||
mInfoWindowView = LayoutInflater.from( mContext ).inflate( R.layout.view_map_data_user_info_window, null );
|
||||
mInfoWindowView = LayoutInflater.from( mContext ).inflate( R.layout.modudle_services_marker_info_window_layout, null );
|
||||
mContentContainer = mInfoWindowView.findViewById( R.id.module_service_id_marker_content );
|
||||
mUserHeader = mInfoWindowView.findViewById( R.id.module_service_id_user_header );
|
||||
mContent = mInfoWindowView.findViewById( R.id.module_service_id_content );
|
||||
|
||||
@@ -7,12 +7,10 @@ import com.mogo.module.service.network.bean.DemoUserInfoEntity;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -32,12 +30,11 @@ public interface RefreshApiService {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST( "/yycp-launcherSnapshot/user/queryOnLineCarWithRoute" )
|
||||
Observable<MarkerResponse> queryOnLineCarWithRoute(@FieldMap Map< String, Object > parameters );
|
||||
Observable< MarkerResponse > queryOnLineCarWithRoute( @FieldMap Map< String, Object > parameters );
|
||||
|
||||
/**
|
||||
* 查询演示车用户信息
|
||||
*/
|
||||
@GET("/yycp-launcherSnapshot/mock/getMockUserInfos")
|
||||
@GET( "/yycp-launcherSnapshot/mock/getMockUserInfos" )
|
||||
Observable< DemoUserInfoEntity > getMockUsers();
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
@@ -47,6 +48,10 @@ public class RefreshModel {
|
||||
this.mRefreshApiService = network.create( RefreshApiService.class, getNetHost() );
|
||||
}
|
||||
|
||||
public RefreshApiService getRefreshApiService() {
|
||||
return mRefreshApiService;
|
||||
}
|
||||
|
||||
public static String getNetHost() {
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
@@ -105,6 +110,51 @@ public class RefreshModel {
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshExplorerWayData( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
|
||||
if ( mRefreshApiService != null ) {
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
|
||||
String data = GsonUtil.jsonFromObject( refreshBody );
|
||||
query.put( "data", data );
|
||||
Logger.d( TAG, data );
|
||||
|
||||
|
||||
mRefreshApiService.refreshDataSync( query )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< MarkerResponse >( RequestOptions.create( mContext ) ) {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse o ) {
|
||||
super.onSuccess( o );
|
||||
if ( callback != null ) {
|
||||
callback.onSuccess( o );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( Throwable e ) {
|
||||
super.onError( e );
|
||||
if ( callback != null ) {
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
if ( callback != null ) {
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshDataSync( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
|
||||
if ( mRefreshApiService != null ) {
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
|
||||
@@ -113,6 +163,7 @@ public class RefreshModel {
|
||||
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
|
||||
refreshBody.dataType.add( ServiceConst.CARD_TYPE_USER_DATA );
|
||||
|
||||
String data = GsonUtil.jsonFromObject( refreshBody );
|
||||
query.put( "data", data );
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.service.network;
|
||||
|
||||
import com.mogo.module.service.network.bean.LauncherCardAdvertisementData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
* <p>
|
||||
* 接口描述
|
||||
*/
|
||||
public interface ZhidaoApiService {
|
||||
|
||||
/**
|
||||
* 获取桌面卡片配置
|
||||
*
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
@GET( "/marketing/advertisingPosition/getCarAdvertisingList" )
|
||||
Observable< LauncherCardAdvertisementData > getCarAdvertisingList( @QueryMap Map< String, Object > parameters );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.module.service.network;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
* <p>
|
||||
* 使用智道的域名
|
||||
*/
|
||||
public class ZhidaoRefreshModel {
|
||||
|
||||
private static final String TAG = "RefreshModel";
|
||||
|
||||
public static final String HOST_DEV = "http://carlife-test.zhidaohulian.com";
|
||||
public static final String HOST_TEST = "http://carlife-test.zhidaohulian.com";
|
||||
public static final String HOST_DEMO = "http://carlife-test.zhidaohulian.com";
|
||||
public static final String HOST_PRODUCT = "https://api.zhidaohulian.com";
|
||||
|
||||
private final Context mContext;
|
||||
private ZhidaoApiService mRefreshApiService;
|
||||
|
||||
public ZhidaoRefreshModel( Context context ) {
|
||||
this.mContext = context;
|
||||
IMogoNetwork network = ( IMogoNetwork ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_NETWORK ).navigation( context );
|
||||
this.mRefreshApiService = network.create( ZhidaoApiService.class, getNetHost() );
|
||||
}
|
||||
|
||||
public ZhidaoApiService getRefreshApiService() {
|
||||
return mRefreshApiService;
|
||||
}
|
||||
|
||||
public static String getNetHost() {
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_TEST;
|
||||
case DebugConfig.NET_MODE_DEMO:
|
||||
return HOST_DEMO;
|
||||
default:
|
||||
return HOST_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.module.service.network.bean;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/8/24
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class LauncherCardAdvertisementData extends BaseData {
|
||||
|
||||
// 启动展示
|
||||
public static final int TYPE_DEFAULT_CONFIG = 1;
|
||||
// 活动
|
||||
public static final int TYPE_ACTIVITY = 2;
|
||||
|
||||
public List< LauncherCardAdvertisement > result;
|
||||
|
||||
/**
|
||||
* 卡片名称 name
|
||||
* 卡片类型 fileType 1-启动展示、2-活动播报
|
||||
* 卡片样式 filePath
|
||||
* 卡片文案 cardContent
|
||||
* 按钮文案 url
|
||||
* 语音文案 content
|
||||
* 活动期限 是时间戳 ,还是标准时间 startTime endTime Date类型
|
||||
* 播报频次(间隔):popupNum
|
||||
* 活动展示顺序 sort
|
||||
*/
|
||||
public static class LauncherCardAdvertisement {
|
||||
public String id;
|
||||
public String name;
|
||||
public int cardType;
|
||||
public String filePath;
|
||||
public String cardContent;
|
||||
public String buttonContent;
|
||||
public String content;
|
||||
public int sort;
|
||||
public long startTime;
|
||||
public long endTime;
|
||||
public int popupNum; // 间隔时间:分钟
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -15,6 +16,8 @@ public
|
||||
* 描述
|
||||
*/
|
||||
class AccStatusReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "AccStatusReceiver";
|
||||
|
||||
// 诺威达 acc 状态
|
||||
public static final String PARAM_ACC_STATUS = "extra_mcu_state";
|
||||
@@ -24,6 +27,7 @@ class AccStatusReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
Logger.d(TAG, "收到诺威达acc广播");
|
||||
MarkerServiceHandler.init( context );
|
||||
IntentHandlerFactory.getInstance().handle( context, intent.getAction(), intent );
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_MOGO = "com.mogo.ACTION";
|
||||
|
||||
// 同行者 查询xxx堵不堵发送的广播
|
||||
public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user