From 0897ec80798adc48a2856f38fc4b10dbac559e3c Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 25 Sep 2020 19:40:19 +0800 Subject: [PATCH] 1. opt --- .../com/mogo/module/main/SchemeIntent.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java index c6199eac00..dfb17641d0 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/SchemeIntent.java @@ -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 ); } } }