This commit is contained in:
wangcongtao
2020-09-25 19:40:19 +08:00
parent 35b452c4c7
commit 0897ec8079

View File

@@ -10,11 +10,8 @@ import com.mogo.module.common.ModuleNames;
import com.mogo.module.main.livedata.CardInfo;
import com.mogo.module.main.livedata.CardSwitchLiveData;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.AppUtils;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
@@ -46,7 +43,17 @@ public class SchemeIntent implements IMogoStatusChangedListener {
private IMogoServiceApis mApis;
private Context mContext;
private Intent mNextIntent;
private IntentWrapper mNextIntent;
private static class IntentWrapper {
public Intent mIntent;
public long mDelay = 0L;
public IntentWrapper( Intent intent, long delay ) {
this.mIntent = intent;
this.mDelay = delay;
}
}
private SchemeIntent() {
// private constructor
@@ -82,7 +89,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
}
if ( !mApis.getStatusManagerApi().isMainPageOnResume() ) {
mNextIntent = intent;
long delay = 0L;
if ( isNaviIntent( intent ) ) {
delay = 2_000L;
}
mNextIntent = new IntentWrapper( intent, delay );
mApis.getLauncherApi().backToLauncher( mContext );
return;
}
@@ -106,6 +117,15 @@ public class SchemeIntent implements IMogoStatusChangedListener {
mNextIntent = null;
}
private boolean isNaviIntent( Intent intent ) {
if ( intent == null || intent.getData() == null ) {
return false;
}
Uri target = intent.getData();
String type = target.getQueryParameter( "type" );
return TextUtils.equals( TYPE_NAVI, type );
}
private void handleSwitch2Action( Uri target ) {
String type = target.getQueryParameter( "type" );
if ( TextUtils.isEmpty( type ) ) {
@@ -187,11 +207,14 @@ public class SchemeIntent implements IMogoStatusChangedListener {
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.MAIN_PAGE_RESUME ) {
if ( mNextIntent == null ) {
return;
}
if ( isTrue ) {
// 保证回到桌面后在开始该规划路线。
UiThreadHandler.postDelayed( () -> {
handle( mNextIntent );
}, 2_000L );
handle( mNextIntent.mIntent );
}, mNextIntent.mDelay );
}
}
}