bugfix: UI-321,UI-322
This commit is contained in:
@@ -121,4 +121,12 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if ( mPresenter != null ) {
|
||||
mPresenter.onDestroy( getViewLifecycleOwner() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -13,7 +24,9 @@ import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoVoiceCmdCallBack {
|
||||
public class AppNavigatorPresenter extends Presenter< AppNavigatorView > implements IMogoIntentListener {
|
||||
|
||||
IMogoIntentManager mIntentManager;
|
||||
|
||||
public AppNavigatorPresenter( AppNavigatorView view ) {
|
||||
super( view );
|
||||
@@ -22,59 +35,55 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume( @NonNull LifecycleOwner owner ) {
|
||||
super.onResume( owner );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL, AppsConst.CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS, this );
|
||||
AIAssist.getInstance( getContext() ).registerUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL, AppsConst.CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS, this );
|
||||
mIntentManager.registerIntentListener( AppsConst.COMMAND_OPERATION, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause( @NonNull LifecycleOwner owner ) {
|
||||
super.onPause( owner );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_OPEN_APPS_PANEL );
|
||||
AIAssist.getInstance( getContext() ).unregisterUnWakeupCommand( AppsConst.CMD_CLOSE_APPS_PANEL );
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
if ( mView == null ) {
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
if ( !AppsConst.COMMAND_OPERATION.equals( intentStr ) ) {
|
||||
return;
|
||||
}
|
||||
switch ( cmd ) {
|
||||
case AppsConst.CMD_OPEN_APPS_PANEL:
|
||||
mView.openAppsPanel();
|
||||
break;
|
||||
case AppsConst.CMD_CLOSE_APPS_PANEL:
|
||||
mView.closeAppsPanel();
|
||||
break;
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( AppsConst.OBJECT_ALL_APPS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
mView.openAppsPanel();
|
||||
} else if ( AppsConst.OPERATION_CLOSE.equals( operation ) ) {
|
||||
mView.closeAppsPanel();
|
||||
}
|
||||
} else if ( AppsConst.OBJECT_FAST_SETTINGS.equals( app ) ) {
|
||||
if ( AppsConst.OPERATION_OPEN.equals( operation ) ) {
|
||||
try {
|
||||
LaunchUtils.launchByPkg( getContext(), AppsConst.APP_PKG_CAR_SETTINGS );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( R.string.module_apps_str_no_app );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdAction( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCmdCancel( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakEnd( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakSelectTimeOut( String speakText ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
if ( mIntentManager != null ) {
|
||||
mIntentManager.unregisterIntentListener( AppsConst.COMMAND_OPERATION );
|
||||
}
|
||||
super.onDestroy( owner );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,16 @@ package com.mogo.module.apps;
|
||||
*/
|
||||
public class AppsConst {
|
||||
|
||||
/**
|
||||
* 打开/关闭全部应用、打开/关闭车辆设置
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
/**
|
||||
* 每页显示多少个app
|
||||
*/
|
||||
public static final int TOTAL_SIZE_EACH_PAGE = 12;
|
||||
|
||||
public static final String CMD_OPEN_APPS_PANEL = "CMD_OPEN_APPS_PANEL";
|
||||
public static final String[] CMD_OPEN_APPS_PANEL_UN_WAKEUP_WORDS = {"打开全部应用"};
|
||||
|
||||
public static final String CMD_CLOSE_APPS_PANEL = "CMD_CLOSE_APPS_PANEL";
|
||||
public static final String[] CMD_CLOSE_APPS_PANEL_UN_WAKEUP_WORDS = {"关闭全部应用"};
|
||||
|
||||
/**
|
||||
* 媒体跳转
|
||||
*/
|
||||
@@ -27,4 +26,11 @@ public class AppsConst {
|
||||
* 车辆设置跳转
|
||||
*/
|
||||
public static final String APP_PKG_CAR_SETTINGS = "com.zhidao.settings";
|
||||
|
||||
public static final String OBJECT_ALL_APPS = "全部应用";
|
||||
public static final String OBJECT_FAST_SETTINGS = "快捷设置";
|
||||
public static final String OPERATION_OPEN = "打开";
|
||||
public static final String OPERATION_CLOSE = "关闭";
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user