1. 高德导航引导按钮白天模式

2. 解决后台被杀后无法操作地图的问题
This commit is contained in:
wangcongtao
2020-09-25 11:15:35 +08:00
parent 5dc2bafac6
commit 3c8745ad8a
34 changed files with 174 additions and 56 deletions

View File

@@ -202,6 +202,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onCreate( Bundle bundle ) {
Logger.d( TAG, Log.getStackTraceString( new Throwable( ) ) );
if ( mMapView != null ) {
mMapView.onCreate( bundle );
Logger.d( TAG, "map onCreate" );

View File

@@ -172,6 +172,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
private UploadButtonAnimatorController mUploadButtonAnimatorController;
private IFragmentProvider mMessageHistoryPanelProvider;
@Override
protected int getLayoutId() {
return R.layout.module_ext_layout_entrance;
@@ -317,8 +319,10 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mMsgContainer.setOnClickListener(view -> {
try {
IFragmentProvider provider = (IFragmentProvider)ARouter.getInstance().build("/push/ui/message").navigation(getContext());
provider.createFragment( getActivity(), mMogoFragmentManager.getMessageHistoryContainerId(), null );
if ( mMessageHistoryPanelProvider == null ) {
mMessageHistoryPanelProvider = (IFragmentProvider)ARouter.getInstance().build("/push/ui/message").navigation(getContext());
}
mMessageHistoryPanelProvider.createFragment( getActivity(), mMogoFragmentManager.getMessageHistoryContainerId(), null );
} catch( Exception e ){
}
@@ -806,8 +810,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
return;
}
mCameraMode.setSelected(ui == EnumMapUI.NorthUP_2D);
mCameraMode.setText(getString(ui == EnumMapUI.NorthUP_2D ? R.string.mode_car_up :
R.string.mode_north_up));
mCameraMode.setText(getString(ui == EnumMapUI.NorthUP_2D ? R.string.mode_car_up : R.string.mode_north_up));
}
@Override

View File

@@ -34,4 +34,10 @@ class SimpleSpeedFragment: MvpFragment<SimpleSpeedFragment, SimpleSpeedPresenter
}
}
}
override fun onDestroyView() {
mPresenter?.destroy()
super.onDestroyView()
}
}

View File

@@ -3,8 +3,11 @@ package com.zhidao.mogo.module.left.panel.presenter
import android.os.Handler
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.mvp.Presenter
import com.mogo.map.IDestroyable
import com.mogo.module.common.MogoApisHandler
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.left.panel.LeftPanelConst.MODULE_NAME
import com.zhidao.mogo.module.left.panel.fragment.SimpleSpeedFragment
@@ -13,12 +16,17 @@ import com.zhidao.mogo.module.left.panel.fragment.SimpleSpeedFragment
*
* @author tongchenfei
*/
class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter<SimpleSpeedFragment>(view) {
class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter<SimpleSpeedFragment>(view), IDestroyable {
companion object {
@JvmField
val TAG: String = "SimpleSpeedPresenter.kt"
}
private val handler = Handler()
private var mogoApis: IMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.context) as IMogoServiceApis
init {
// 注册相关回调,监测速度变化
mogoApis.registerCenterApi.registerMogoLocationListener(MODULE_NAME) {
MogoApisHandler.getInstance()?.apis?.registerCenterApi?.registerMogoLocationListener(MODULE_NAME) {
handler.post {
mView.refreshSpeed((it.speed * 3.6).toInt())
}
@@ -38,4 +46,9 @@ class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter<SimpleSpeedFra
//
// })
}
override fun destroy() {
Logger.d(TAG, "destroy")
MogoApisHandler.getInstance()?.apis?.registerCenterApi?.unregisterMogoLocationListener(MODULE_NAME)
}
}

View File

@@ -102,6 +102,7 @@ public class MogoModulesManager implements MogoModulesHandler {
@Override
public void loadMapModule( int containerId ) {
Logger.d( TAG, "loadMapModule" );
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
.build( MogoModulePaths.PATH_MODULE_MAP )
.navigation( getContext() );
@@ -181,7 +182,11 @@ public class MogoModulesManager implements MogoModulesHandler {
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;
}
final Fragment fragment = provider.createFragment( getContext(), null );
Fragment fragment = null;
fragment = mActivity.getSupportFragmentManager().findFragmentByTag( provider.getModuleName() );
if ( fragment == null ) {
fragment = provider.createFragment( getContext(), null );
}
if ( fragment == null ) {
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;

View File

@@ -16,6 +16,7 @@ import com.mogo.service.obu.IMogoObuDataChangedListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author congtaowang
@@ -29,7 +30,7 @@ public class MogoRegisterCenterHandler implements IMogoRegisterCenter {
private Map< String, IMogoModuleLifecycle > mLifecycle = new HashMap<>();
private Map< String, IMogoMapListener > mMap = new HashMap<>();
private Map< String, IMogoNaviListener > mNavi = new HashMap<>();
private Map< String, IMogoNaviListener > mNavi = new ConcurrentHashMap<>();
private Map< String, IMogoLocationListener > mLocation = new HashMap<>();
private Map< String, IMogoMarkerClickListener > mMarker = new HashMap<>();
private Map< String, IMogoAimlessModeListener > mAimless = new HashMap<>();

View File

@@ -16,6 +16,7 @@ import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
@@ -60,6 +61,7 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
@Override
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
Logger.d( TAG, "onActivityCreated" );
initMapView();
}

View File

@@ -36,4 +36,10 @@ class PushHistoryUiProvider implements IFragmentProvider {
public void init( Context context ) {
}
@Override
public void onDestroy() {
}
}

View File

@@ -956,6 +956,7 @@ public class MogoServices implements IMogoMapListener,
@Override
public void onStopNavi() {
SpStorage.setNavigationTarget( "" );
Logger.d( TAG, "onStopNavi: remove MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH msg" );
mHandler.removeMessages( ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH );
}

View File

@@ -22,4 +22,6 @@ interface IOnlineCarPanelView extends IView {
void renderNoNavigationInfoUi();
void renderErrorUi();
void removeSelf();
}

View File

@@ -30,10 +30,14 @@ class OnlineCarListPanelProvider implements IMogoOnlineCarListPanelProvider {
@Override
public void showPanel() {
if ( isFragmentExist( ContainerHandler.sAttachContext ) ) {
Fragment fragment = null;
if ( ( fragment = isFragmentAdded( ContainerHandler.sAttachContext ) ) != null ) {
if ( fragment instanceof OnlineCarPanelFragment ) {
( ( OnlineCarPanelFragment ) fragment ).refreshPanel();
}
return;
}
Fragment fragment = new OnlineCarPanelFragment();
fragment = new OnlineCarPanelFragment();
ContainerHandler.sAttachContext
.getSupportFragmentManager()
.beginTransaction()
@@ -41,15 +45,16 @@ class OnlineCarListPanelProvider implements IMogoOnlineCarListPanelProvider {
.commitNowAllowingStateLoss();
}
private boolean isFragmentExist( Context context ) {
private Fragment isFragmentAdded( Context context ) {
if ( !( context instanceof FragmentActivity ) ) {
Logger.w( TAG, "context is not a instance of FragmentActivity" );
return false;
return null;
}
Fragment fragment = null;
return ( fragment = ( ( FragmentActivity ) context )
.getSupportFragmentManager()
.findFragmentByTag( TAG ) ) != null && fragment.isAdded();
.findFragmentByTag( TAG ) ) != null && fragment.isAdded()
? fragment : null;
}
@Override

View File

@@ -47,7 +47,7 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
@Override
protected void initViews() {
findViewById( R.id.module_services_id_close ).setOnClickListener( view -> {
MarkerServiceHandler.getApis().getOnlineCarPanelApi().hidePanel();
removeSelf();
} );
mList = findViewById( R.id.module_services_id_recycler_view );
mRefreshPanel = findViewById( R.id.module_services_id_load_strategy_container );
@@ -70,6 +70,10 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
} );
}
public void refreshPanel(){
mPresenter.refreshPanel();
}
@Override
public void showLoading( boolean visible ) {
if ( visible ) {
@@ -147,4 +151,17 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
mLoading.setVisibility( View.GONE );
mErrorPanel.setVisibility( View.VISIBLE );
}
@Override
public void removeSelf() {
MarkerServiceHandler.getApis().getOnlineCarPanelApi().hidePanel();
}
@Override
public void onDestroyView() {
if ( mPresenter != null ) {
mPresenter.destroy();
}
super.onDestroyView();
}
}

View File

@@ -7,10 +7,14 @@ import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.storage.SpStorage;
import com.mogo.map.IDestroyable;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoNaviListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.service.network.RefreshCallback;
import com.mogo.module.service.network.RefreshModel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
/**
@@ -19,7 +23,12 @@ import com.mogo.utils.network.utils.GsonUtil;
* <p>
* 描述
*/
class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implements RefreshCallback< MarkerResponse > {
class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implements
RefreshCallback< MarkerResponse >,
IMogoNaviListener2,
IDestroyable {
private static final String TAG = "OnlineCarPanelPresenter";
public static final int LIMIT = 20;
private RefreshModel mRefreshModel;
@@ -31,19 +40,18 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
public OnlineCarPanelPresenter( IOnlineCarPanelView view ) {
super( view );
mRefreshModel = new RefreshModel( getContext() );
mStrategy = OnlineCarStrategy.Default;
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoNaviListener( TAG, this );
}
@Override
public void onStopNavi() {
mView.removeSelf();
}
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
String json = SpStorage.getNavigationTarget();
if ( TextUtils.isEmpty( json ) ) {
mView.renderNoNavigationInfoUi();
return;
}
mNavigationTargetInfo = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
loadOnlineCar();
refreshPanel();
}
public void nextStrategy() {
@@ -55,8 +63,21 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
}
}
public void refreshPanel() {
mStrategy = OnlineCarStrategy.Default;
String json = SpStorage.getNavigationTarget();
if ( TextUtils.isEmpty( json ) ) {
mView.renderNoNavigationInfoUi();
return;
}
Logger.d( TAG, json );
mNavigationTargetInfo = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
loadOnlineCar();
}
public void loadOnlineCar() {
if ( mNavigationTargetInfo == null ) {
mView.renderNoNavigationInfoUi();
return;
}
mView.showLoading( true );
@@ -92,4 +113,9 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
public void onFail() {
mView.renderErrorUi();
}
@Override
public void destroy() {
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoNaviListener( TAG );
}
}

View File

@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="@dimen/module_widgets_app_bkg_corner" />
<corners android:bottomLeftRadius="0px" android:bottomRightRadius="@dimen/module_widgets_app_bkg_corner" android:topLeftRadius="0px" android:topRightRadius="@dimen/module_widgets_app_bkg_corner" />
<solid android:color="#3D3F44" />
</shape>
</item>

View File

@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:bottomLeftRadius="0px" android:bottomRightRadius="0px" android:topLeftRadius="@dimen/module_widgets_app_bkg_corner" android:topRightRadius="@dimen/module_widgets_app_bkg_corner" />
<corners android:bottomLeftRadius="@dimen/module_widgets_app_bkg_corner" android:bottomRightRadius="0px" android:topLeftRadius="@dimen/module_widgets_app_bkg_corner" android:topRightRadius="0px" />
<solid android:color="#3D3F44" />
</shape>
</item>

View File

@@ -1,31 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/module_widgets_app_entrance_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/module_widgets_app_handler_container"
android:layout_width="@dimen/module_widgets_app_handler_width"
android:layout_height="match_parent"
android:background="@drawable/module_widgets_app_handler_bkg"
android:gravity="center">
<ImageView
android:id="@+id/module_widgets_app_handler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_widgets_app_handler_close" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/module_widgets_app_body_bkg">
<LinearLayout
android:id="@+id/module_widgets_app_handler_container"
android:layout_width="@dimen/module_widgets_app_handler_width"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="@+id/module_widgets_app_handler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_widgets_app_handler_close" />
</LinearLayout>
<TextView
android:id="@+id/module_widgets_app_entrance"
android:layout_width="wrap_content"
@@ -62,4 +60,4 @@
</LinearLayout>
</FrameLayout>
</LinearLayout>

View File

@@ -3,7 +3,7 @@
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
<dimen name="module_widgets_app_entrance_padding">15px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">2px</dimen>
<dimen name="module_widgets_app_entrance_y">505px</dimen>
<dimen name="module_widgets_app_entrance_y">503px</dimen>
<dimen name="module_widgets_app_entrance_x">501px</dimen>
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>

View File

@@ -3,7 +3,7 @@
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
<dimen name="module_widgets_app_entrance_padding">15px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">2px</dimen>
<dimen name="module_widgets_app_entrance_y">505px</dimen>
<dimen name="module_widgets_app_entrance_y">503px</dimen>
<dimen name="module_widgets_app_entrance_x">501px</dimen>
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>

View File

@@ -3,8 +3,8 @@
<dimen name="module_widgets_app_entrance_textSize">40px</dimen>
<dimen name="module_widgets_app_entrance_padding">30px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
<dimen name="module_widgets_app_entrance_y">836px</dimen>
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
<dimen name="module_widgets_app_entrance_y">906px</dimen>
<dimen name="module_widgets_app_entrance_x">1316px</dimen>
<dimen name="module_widgets_app_entrance_paddingTop">37px</dimen>
<dimen name="module_widgets_app_entrance_paddingLeft">50px</dimen>
<dimen name="module_widgets_app_entrance_size">71px</dimen>

View File

@@ -3,8 +3,8 @@
<dimen name="module_widgets_app_entrance_textSize">40px</dimen>
<dimen name="module_widgets_app_entrance_padding">30px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
<dimen name="module_widgets_app_entrance_y">836px</dimen>
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
<dimen name="module_widgets_app_entrance_y">906px</dimen>
<dimen name="module_widgets_app_entrance_x">1316px</dimen>
<dimen name="module_widgets_app_entrance_paddingTop">37px</dimen>
<dimen name="module_widgets_app_entrance_paddingLeft">50px</dimen>
<dimen name="module_widgets_app_entrance_size">71px</dimen>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
<dimen name="module_widgets_app_entrance_padding">30px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
<dimen name="module_widgets_app_entrance_y">505px</dimen>
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
<dimen name="module_widgets_app_entrance_padding">15px</dimen>
<dimen name="module_widgets_app_entrance_corner_size">2px</dimen>
<dimen name="module_widgets_app_entrance_y">503px</dimen>
<dimen name="module_widgets_app_entrance_x">501px</dimen>
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>
<dimen name="module_widgets_app_entrance_size">71px</dimen>

View File

@@ -17,4 +17,6 @@ public
interface IFragmentProvider extends IProvider {
Fragment createFragment( FragmentActivity activity, int containerId, Bundle date );
public void onDestroy();
}

View File

@@ -1,7 +1,5 @@
package com.mogo.service.strategy;
import android.content.Context;
import androidx.annotation.IdRes;
import androidx.fragment.app.FragmentActivity;

View File

@@ -43,6 +43,7 @@ android {
'src/main/module-tanlu-res',
'src/main/module-commons-res',
'src/main/module-media-res',
'src/main/mogo-module-widgets-res',
]
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="@dimen/module_ext_common_corner" />
<solid android:color="#E6262626" />
</shape>
</item>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:bottomLeftRadius="0px" android:bottomRightRadius="@dimen/module_widgets_app_bkg_corner" android:topLeftRadius="0px" android:topRightRadius="@dimen/module_widgets_app_bkg_corner" />
<solid android:color="#E6FFFFFF" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:bottomLeftRadius="0px" android:bottomRightRadius="0px" android:topLeftRadius="@dimen/module_widgets_app_bkg_corner" android:topRightRadius="0px" />
<solid android:color="#E6F5F5F5" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_widgets_app_entrance_textColor_light">#333333</color>
</resources>