[Update] 升级ARouter 版本,支持Fragment单利
[Change] 修改地图层、HMI层加载方式,采用ARouter方式获取Fragment实例进行加载;废弃MoGoWarningProvider使用MoGoHmiFragment接管IMoGoWaringProvider实现 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -96,16 +96,6 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
@Override
|
||||
protected void beforeSetContentView(Bundle savedInstanceState) {
|
||||
init();
|
||||
installSkinManager(savedInstanceState);
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装皮肤支持
|
||||
*
|
||||
* @param savedInstanceState
|
||||
*/
|
||||
private void installSkinManager(Bundle savedInstanceState) {
|
||||
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().createMapViewInstance(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +198,7 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
loadOthersModules();
|
||||
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
});
|
||||
MogoModulesManager.getInstance().loadMapModule(R.id.module_main_id_map_fragment_container);
|
||||
loadFunctionMapView();
|
||||
} else {
|
||||
loadOthersModules();
|
||||
}
|
||||
@@ -243,8 +233,8 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
* 加载其它模块
|
||||
*/
|
||||
protected void loadOthersModules() {
|
||||
//loadFunctionFragment();
|
||||
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
|
||||
loadFunctionFragment();
|
||||
loadContainerModules();
|
||||
MogoModulesManager.getInstance().loadModules();
|
||||
MogoModulesManager.getInstance().loadFunctionModules();
|
||||
@@ -270,9 +260,9 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
}
|
||||
|
||||
protected void loadContainerModules() {
|
||||
//MogoModulesManager.getInstance().loadWaringModule(R.id.module_main_id_waring_fragment);
|
||||
MogoModulesManager.getInstance().loadEntrancesModule(R.id.module_main_id_entrance_fragment_container);
|
||||
MogoModulesManager.getInstance().loadEventPanelModule(R.id.module_main_id_event_panel_fragment_container);
|
||||
MogoModulesManager.getInstance().loadWaringModule(R.id.module_main_id_waring_fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,8 +274,17 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
|
||||
@Override
|
||||
public void loadFunctionFragment() {
|
||||
// 加载 HMI 框架
|
||||
MvpFragment fragmentHdMap = (MvpFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_HMI).navigation();
|
||||
addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_waring_fragment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载地图视图
|
||||
*/
|
||||
private void loadFunctionMapView() {
|
||||
MvpFragment fragmentHdMap = (MvpFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_MAP).navigation();
|
||||
addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_hd_map_fragment_container);
|
||||
addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_map_fragment_container);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -399,7 +398,6 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
mMogoFragmentManager.unregisterMainFragmentStackTransactionListener();
|
||||
mMogoFragmentManager.destroy();
|
||||
mMogoFragmentManager = null;
|
||||
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().destroy();
|
||||
mServiceApis.getMapServiceApi().getMapUIController().destroy();
|
||||
AdasConfigApiController.getInstance().release();
|
||||
mServiceApis.getAdasControllerApi().release();
|
||||
|
||||
@@ -27,13 +27,6 @@ public interface MogoModulesHandler {
|
||||
*/
|
||||
void loadFunctionModulesServer();
|
||||
|
||||
/**
|
||||
* 加载地图
|
||||
*
|
||||
* @param containerId 容器id
|
||||
*/
|
||||
void loadMapModule(int containerId);
|
||||
|
||||
/**
|
||||
* 加载所有应用
|
||||
*
|
||||
@@ -56,12 +49,6 @@ public interface MogoModulesHandler {
|
||||
*/
|
||||
void loadBaseModule();
|
||||
|
||||
/**
|
||||
* 加载预警面板
|
||||
*
|
||||
* @param containerId
|
||||
*/
|
||||
void loadWaringModule(int containerId);
|
||||
|
||||
/**
|
||||
* 加载事件面板
|
||||
|
||||
@@ -9,13 +9,12 @@ import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.main.MainActivity;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -129,14 +128,6 @@ 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() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAppsListModule( int containerId ) {
|
||||
@@ -172,14 +163,6 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWaringModule(int containerId) {
|
||||
IMoGoFunctionProvider provider = ( IMoGoFunctionProvider ) ARouter.getInstance()
|
||||
.build( MogoServicePaths.PATH_HMI)
|
||||
.navigation( getContext() );
|
||||
addFragment( provider, containerId );
|
||||
}
|
||||
|
||||
|
||||
private IProvider loadBaseProvider(String path ) {
|
||||
try {
|
||||
@@ -236,23 +219,6 @@ public class MogoModulesManager implements MogoModulesHandler {
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void addFragment( IMoGoFunctionProvider provider, int containerId ) {
|
||||
if ( provider == null ) {
|
||||
Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
}
|
||||
Fragment fragment = mActivity.getSupportFragmentManager().findFragmentByTag( provider.getFunctionName() );
|
||||
if ( fragment == null ) {
|
||||
fragment = provider.createCoverage( mActivity, null );
|
||||
}
|
||||
if ( fragment == null ) {
|
||||
Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
|
||||
return;
|
||||
}
|
||||
mActivity.getSupportFragmentManager().beginTransaction()
|
||||
.replace( containerId, fragment, provider.getFunctionName() )
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- 地图 -->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_hd_map_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
<!--四个方向,碰撞预警-->
|
||||
<FrameLayout
|
||||
|
||||
@@ -6,7 +6,9 @@ import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.MogoMapView;
|
||||
@@ -17,11 +19,13 @@ import com.mogo.service.map.IMogoMapFrameController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* @author donghongyu
|
||||
* @since 2021-11-09
|
||||
* 高精度地图层UI
|
||||
* <p>
|
||||
* 地图图层,地图操作都在这个图层完成
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP)
|
||||
public class MapFragment extends MvpFragment< MapView, MapPresenter > implements MapView, IMogoMapFrameController {
|
||||
|
||||
private static final String TAG = "MapFragment";
|
||||
|
||||
@@ -28,9 +28,7 @@ public class MapFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
MapFragment mMapFragment = new MapFragment();
|
||||
mMapFragment.setArguments( data );
|
||||
return mMapFragment;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
Reference in New Issue
Block a user