修改独立app页面销毁后部分监听没有注销的问题
This commit is contained in:
@@ -58,7 +58,6 @@ import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.glide.GlideApp;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.roadcondition.service.DelayService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -76,7 +75,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
IMogoNaviListener,
|
||||
IMogoMapListener,
|
||||
IMogoAimlessModeListener,
|
||||
IMogoStatusChangedListener {
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener{
|
||||
|
||||
private static final String TAG = "EntranceFragment";
|
||||
|
||||
@@ -239,27 +239,17 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
} else {
|
||||
mMApUIController.changeMapMode(EnumMapUI.NorthUP_2D);
|
||||
}
|
||||
mCameraMode.setSelected( !mCameraMode.isSelected() );
|
||||
mCameraMode.setText( getString( mCameraMode.isSelected() ? R.string.mode_car_up : R.string.mode_north_up ) );
|
||||
} );
|
||||
// mCameraMode.setSelected(!mCameraMode.isSelected());
|
||||
// mCameraMode.setText(getString(mCameraMode.isSelected() ? R.string.mode_car_up :
|
||||
// R.string.mode_north_up));
|
||||
});
|
||||
|
||||
mApis.getIntentManagerApi().registerIntentListener( AUTONAVI_STANDARD_BROADCAST_RECV, (( intentStr, intent ) -> {
|
||||
int key_type = intent.getIntExtra( "KEY_TYPE", 0 );
|
||||
int type = intent.getIntExtra( "EXTRA_TYPE", -1 );
|
||||
int opera_type = intent.getIntExtra( "EXTRA_OPERA", -1 );
|
||||
if ( key_type == 10027 ) {
|
||||
if ( opera_type == 0 ) {
|
||||
mCameraMode.setSelected( false );
|
||||
} else if ( opera_type == 1 ) {
|
||||
mCameraMode.setSelected( true );
|
||||
}
|
||||
mCameraMode.setText( getString( mCameraMode.isSelected() ? R.string.mode_car_up : R.string.mode_north_up ) );
|
||||
} else if( key_type == 10021 ){
|
||||
onStopNavi();
|
||||
}
|
||||
}) );
|
||||
MogoEntranceButtons.save( ButtonIndex.BUTTON1, findViewById( R.id.module_entrance_id_button1 ) );
|
||||
MogoEntranceButtons.save( ButtonIndex.BUTTON2, findViewById( R.id.module_entrance_id_button2 ) );
|
||||
|
||||
mApis.getIntentManagerApi().registerIntentListener(AUTONAVI_STANDARD_BROADCAST_RECV, this);
|
||||
MogoEntranceButtons.save(ButtonIndex.BUTTON1,
|
||||
findViewById(R.id.module_entrance_id_button1));
|
||||
MogoEntranceButtons.save(ButtonIndex.BUTTON2,
|
||||
findViewById(R.id.module_entrance_id_button2));
|
||||
|
||||
mDisplayOverviewBounds = new Rect(
|
||||
ResourcesHelper.getDimensionPixelSize(getContext(),
|
||||
@@ -362,6 +352,22 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
isClickShare = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived(String intentStr, Intent intent) {
|
||||
int key_type = intent.getIntExtra("KEY_TYPE", 0);
|
||||
int type = intent.getIntExtra("EXTRA_TYPE", -1);
|
||||
int opera_type = intent.getIntExtra("EXTRA_OPERA", -1);
|
||||
if (key_type == 10027) {
|
||||
if (opera_type == 0) {
|
||||
mCameraMode.setSelected(false);
|
||||
} else if (opera_type == 1) {
|
||||
mCameraMode.setSelected(true);
|
||||
}
|
||||
mCameraMode.setText(getString(mCameraMode.isSelected() ?
|
||||
R.string.mode_car_up : R.string.mode_north_up));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
|
||||
if (naviinfo == null) {
|
||||
@@ -468,11 +474,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mCameraMode.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
} else if (descriptor == StatusDescriptor.ACC_STATUS) {
|
||||
Log.d(TAG, " onStatusChanged isTrue = " + isTrue);
|
||||
if (isTrue) {
|
||||
DelayService.Companion.launchService(getContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,4 +579,32 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
if ( mCameraMode == null ) {
|
||||
return;
|
||||
}
|
||||
mCameraMode.setSelected(ui == EnumMapUI.NorthUP_2D);
|
||||
mCameraMode.setText(getString(ui == EnumMapUI.NorthUP_2D ? R.string.mode_car_up : R.string.mode_north_up));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if ( mMogoRegisterCenter != null ) {
|
||||
mMogoRegisterCenter.unregisterMogoNaviListener(ExtensionsModuleConst.TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoMapListener(ExtensionsModuleConst.TYPE_ENTRANCE);
|
||||
mMogoRegisterCenter.unregisterMogoAimlessModeListener(TAG);
|
||||
}
|
||||
if ( mStatusManager != null ) {
|
||||
mStatusManager.unregisterStatusChangedListener(TAG, StatusDescriptor.UPLOADING, this);
|
||||
mStatusManager.unregisterStatusChangedListener(TAG, StatusDescriptor.DISPLAY_OVERVIEW, this);
|
||||
}
|
||||
if ( mApis != null ) {
|
||||
if ( mApis.getIntentManagerApi() != null ) {
|
||||
mApis.getIntentManagerApi().unregisterIntentListener(AUTONAVI_STANDARD_BROADCAST_RECV, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user