1. 后台重启情况下无法显示目的地车友控件的问题
This commit is contained in:
@@ -23,6 +23,7 @@ import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -40,6 +41,9 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
private static final String TAG = "AutoNaviIntentHandler";
|
||||
public static final String OPEN = "OPEN_APP";
|
||||
|
||||
// 显示浮窗时,同步状态时间间隔
|
||||
public static final long SYNC_INTERVAL = 60_000L;
|
||||
|
||||
private static volatile AutoNaviIntentHandler sInstance;
|
||||
|
||||
private AutoNaviIntentHandler() {
|
||||
@@ -70,27 +74,33 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Runnable mAutoNaviSyncRunnable = () -> {
|
||||
if ( mWindowManagerView != null && mWindowManagerView.isShowing() ) {
|
||||
syncAutoNaviForgroundStatus( AbsMogoApplication.getApp() );
|
||||
}
|
||||
};
|
||||
|
||||
public void handle( Context context, Intent intent ) {
|
||||
int keyType = intent.getIntExtra( "KEY_TYPE", 0 );
|
||||
Logger.d( TAG, "KEY_TYPE = " + keyType );
|
||||
switch ( keyType ) {
|
||||
case 10021:
|
||||
closeEntrance();
|
||||
break;
|
||||
case 10019:
|
||||
int extraState = intent.getIntExtra( "EXTRA_STATE", -1 );
|
||||
Logger.d( TAG, "EXTRA_STATE = " + extraState );
|
||||
switch ( extraState ) {
|
||||
case 3:
|
||||
case 3: // 前台
|
||||
syncAutoNaviNavingStatus( context );
|
||||
break;
|
||||
case 4:
|
||||
case 4: // 后台
|
||||
case 9: // 非导航
|
||||
closeEntrance();
|
||||
break;
|
||||
case 8:
|
||||
case 8: // 导航
|
||||
showEntrance( context );
|
||||
break;
|
||||
case 9:
|
||||
closeEntrance();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -106,6 +116,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
|
||||
private void showEntrance( Context context ) {
|
||||
|
||||
if ( mWindowManagerView == null ) {
|
||||
mWindowManagerView = new WindowManagerView.Builder( AbsMogoApplication.getApp() )
|
||||
.contentView( R.layout.module_widgets_app_entrance )
|
||||
@@ -125,9 +136,16 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
if ( mWindowManagerView.isShowing() ) {
|
||||
return;
|
||||
}
|
||||
if ( MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
mWindowManagerView.show();
|
||||
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "NAVI_button_show", null );
|
||||
AIAssist.getInstance( context ).registerUnWakeupCommand( OPEN, new String[]{"切换到辅助驾驶模式"}, this );
|
||||
UiThreadHandler.postDelayed( mAutoNaviSyncRunnable, SYNC_INTERVAL );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
@@ -221,6 +239,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
|
||||
public void closeEntrance() {
|
||||
UiThreadHandler.removeCallbacks( mAutoNaviSyncRunnable );
|
||||
if ( mWindowManagerView == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -233,6 +252,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
|
||||
public void syncAutoNaviForgroundStatus( Context context ) {
|
||||
Logger.d( TAG, "查询高德前后台状态" );
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
|
||||
intent.putExtra( "KEY_TYPE", 12404 );
|
||||
@@ -241,6 +261,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
|
||||
public void syncAutoNaviNavingStatus( Context context ) {
|
||||
Logger.d( TAG, "查询高德导航状态" );
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" );
|
||||
intent.putExtra( "KEY_TYPE", 12404 );
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -65,7 +66,9 @@ class MogoWidgetManger implements IMogoNaviListener2, IMogoIntentListener, IMogo
|
||||
initMapStatusListener();
|
||||
initStatusListener();
|
||||
initIntentListener();
|
||||
AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
|
||||
UiThreadHandler.postDelayed( ()->{
|
||||
AutoNaviIntentHandler.getInstance().syncAutoNaviForgroundStatus( mContext );
|
||||
}, 1_000L );
|
||||
}
|
||||
|
||||
private void initMapStatusListener() {
|
||||
|
||||
@@ -94,6 +94,6 @@ class MogoWidgetsProvider implements IMogoModuleProvider {
|
||||
Logger.d( TAG, "init." );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MogoWidgetManger.getInstance().init( context );
|
||||
}, 5500 );
|
||||
}, 6_000L );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user