|
|
|
|
@@ -10,7 +10,6 @@ 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.network.Utils;
|
|
|
|
|
import com.mogo.commons.voice.AIAssist;
|
|
|
|
|
import com.mogo.map.MogoLatLng;
|
|
|
|
|
import com.mogo.map.location.MogoLocation;
|
|
|
|
|
@@ -19,7 +18,6 @@ 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.ZhidaoApiService;
|
|
|
|
|
import com.mogo.module.service.network.ZhidaoRefreshModel;
|
|
|
|
|
import com.mogo.module.service.network.bean.LauncherCardAdvertisementData;
|
|
|
|
|
import com.mogo.utils.AppUtils;
|
|
|
|
|
@@ -29,12 +27,8 @@ import com.mogo.utils.storage.SharedPrefsMgr;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
@@ -69,6 +63,7 @@ class LauncherCardRefresher {
|
|
|
|
|
public static final long ONE_MINUTE = 60 * 1000L;
|
|
|
|
|
public static final long ONE_DAY = 24 * 60 * ONE_MINUTE;
|
|
|
|
|
private String mLaunchTTSText;
|
|
|
|
|
private long mDefaultTTSPlayInterval = 3 * ONE_MINUTE;
|
|
|
|
|
private LauncherCardAdvertisementData.LauncherCardAdvertisement mDefaultLauncherCardConfig;
|
|
|
|
|
private List< LauncherCardAdvertisementData.LauncherCardAdvertisement > mAdvertisements;
|
|
|
|
|
|
|
|
|
|
@@ -205,43 +200,17 @@ class LauncherCardRefresher {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MogoLatLng latLng = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
|
|
|
|
if ( mRefreshStrategy.getType() == LauncherCardRefreshType.ExploreWay ) {
|
|
|
|
|
handleRefreshExplorerWayData( latLng );
|
|
|
|
|
} else {
|
|
|
|
|
handleRefreshOnlineCarData( latLng );
|
|
|
|
|
}
|
|
|
|
|
handleRefreshData( latLng, mRefreshStrategy.getType() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleRefreshExplorerWayData( MogoLatLng latLng ) {
|
|
|
|
|
private void handleRefreshData( MogoLatLng latLng, LauncherCardRefreshType type ) {
|
|
|
|
|
mRefreshModel.refreshDataSync( latLng,
|
|
|
|
|
mRefreshStrategy.getRadius(),
|
|
|
|
|
mRefreshStrategy.getLimit(),
|
|
|
|
|
new RefreshCallback< MarkerResponse >() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess( MarkerResponse response ) {
|
|
|
|
|
notifyLauncherCardExplorerWayChanged( LauncherCardRefreshType.ExploreWay, response );
|
|
|
|
|
mRefreshStrategy = mRefreshStrategy.getNext();
|
|
|
|
|
restart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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 ) {
|
|
|
|
|
notifyLauncherCardExplorerWayChanged( LauncherCardRefreshType.OnlineCar, response );
|
|
|
|
|
notifyRefreshChanged( type, response );
|
|
|
|
|
mRefreshStrategy = mRefreshStrategy.getNext();
|
|
|
|
|
restart();
|
|
|
|
|
}
|
|
|
|
|
@@ -255,27 +224,43 @@ class LauncherCardRefresher {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean notifyLauncherCardExplorerWayChanged( 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() ), true );
|
|
|
|
|
notifyLauncherCardExplorerWayChanged( 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() ), true );
|
|
|
|
|
notifyLauncherCardExplorerWayChanged( String.format( info, size, mRefreshStrategy.getDesc() ), size, tts );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -289,7 +274,7 @@ class LauncherCardRefresher {
|
|
|
|
|
AIAssist.getInstance( mContext ).speakTTSVoice( msg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void notifyLauncherCardExplorerWayChanged( 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 );
|
|
|
|
|
@@ -321,6 +306,9 @@ class LauncherCardRefresher {
|
|
|
|
|
if ( !TextUtils.isEmpty( mDefaultLauncherCardConfig.content ) ) {
|
|
|
|
|
mLaunchTTSText = mDefaultLauncherCardConfig.content;
|
|
|
|
|
}
|
|
|
|
|
if ( mDefaultLauncherCardConfig.popupNum > 0 ) {
|
|
|
|
|
mDefaultTTSPlayInterval = mDefaultLauncherCardConfig.popupNum * ONE_MINUTE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -424,7 +412,7 @@ class LauncherCardRefresher {
|
|
|
|
|
private void startLoopDefaultConfigStrategy() {
|
|
|
|
|
Message msg = Message.obtain();
|
|
|
|
|
msg.what = MSG_START_LOOP_DEFAULT_CARD;
|
|
|
|
|
mHandler.sendMessageDelayed( msg, 3 * ONE_MINUTE );
|
|
|
|
|
mHandler.sendMessageDelayed( msg, mDefaultTTSPlayInterval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|