This commit is contained in:
wangcongtao
2020-08-03 21:12:59 +08:00
parent 44ba910d97
commit 5294a6447b
5 changed files with 66 additions and 45 deletions

View File

@@ -8,9 +8,7 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -52,18 +50,14 @@ import com.mogo.service.module.IMogoRegisterCenter;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.LaunchUtils;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidao.roadcondition.service.DelayService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
@@ -77,7 +71,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
IMogoNaviListener,
IMogoMapListener,
IMogoAimlessModeListener,
IMogoStatusChangedListener {
IMogoStatusChangedListener,
IMogoIntentListener{
private static final String TAG = "EntranceFragment";
@@ -354,28 +349,17 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
} 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(),
@@ -447,8 +431,24 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
}
@Override
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
if ( naviinfo == null ) {
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) {
return;
}
if ( mNaviInfo != null ) {
@@ -559,11 +559,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
mCameraMode.setVisibility( View.VISIBLE );
}
}
} else if (descriptor == StatusDescriptor.ACC_STATUS) {
Log.d(TAG, " onStatusChanged isTrue = " + isTrue);
if ( isTrue ) {
DelayService.Companion.launchService(getContext());
}
}
}
@@ -605,4 +600,23 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
// 30s 后无论成功与否,停止动画
mUploadFrameAnimHandler.sendEmptyMessageDelayed( MSG_STOP_ANIM, 30_000 );
}
@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);
}
}
}
}