opt
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-01
|
||||
* <p>
|
||||
* 常量
|
||||
*/
|
||||
public class AppConstants {
|
||||
|
||||
/**
|
||||
* 长链 appId
|
||||
*/
|
||||
public static final String SOCKET_APP_ID = "com.mogo.launcher";
|
||||
}
|
||||
@@ -51,8 +51,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private IMogoMapUIController mMogoMapUIController;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
|
||||
private IMogoSocketManager mMogoSocketManager;
|
||||
|
||||
private OrientedViewPager mCardsContainer;
|
||||
private CardModulesAdapter mCardModulesAdapter;
|
||||
|
||||
@@ -160,9 +158,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient.start();
|
||||
|
||||
mMogoSocketManager = ( IMogoSocketManager ) ARouter.getInstance().build( MogoServicePaths.PATH_SOCKET_MANAGER ).navigation();
|
||||
mMogoSocketManager.init( getApplicationContext(), AppConstants.SOCKET_APP_ID );
|
||||
}
|
||||
|
||||
private void loadModules() {
|
||||
@@ -232,6 +227,5 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoModuleHandler.destroy();
|
||||
mMogoModuleHandler = null;
|
||||
}
|
||||
mMogoSocketManager = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,28 +159,47 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
|
||||
@Override
|
||||
public void setEnable( String module ) {
|
||||
mEnableModuleName = module;
|
||||
|
||||
final Set< Map.Entry< MogoModule, IMogoModuleProvider > > entries = mModuleProviders.entrySet();
|
||||
if ( !entries.isEmpty() ) {
|
||||
for ( Map.Entry< MogoModule, IMogoModuleProvider > entry : entries ) {
|
||||
final MogoModule key = entry.getKey();
|
||||
final IMogoModuleProvider provider = entry.getValue();
|
||||
if ( provider.getType() != ModuleType.TYPE_CARD_FRAGMENT ) {
|
||||
// 仅卡片需要生命周期
|
||||
continue;
|
||||
}
|
||||
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( key.getName() );
|
||||
Iterator< IMogoModuleProvider > iterator = mModuleProviders.values().iterator();
|
||||
int counter = 0;
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoModuleProvider provider = iterator.next();
|
||||
if ( provider == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( provider.getType() != ModuleType.TYPE_CARD_FRAGMENT ) {
|
||||
continue;
|
||||
}
|
||||
if ( TextUtils.equals( mEnableModuleName, provider.getModuleName() ) ) {
|
||||
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( mEnableModuleName );
|
||||
if ( lifecycle != null ) {
|
||||
if ( TextUtils.equals( key.getName(), mEnableModuleName ) ) {
|
||||
lifecycle.onPerform();
|
||||
} else {
|
||||
try {
|
||||
lifecycle.onDisable();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
continue;
|
||||
}
|
||||
if ( TextUtils.equals( module, provider.getModuleName() ) ) {
|
||||
final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( module );
|
||||
if ( lifecycle != null ) {
|
||||
try {
|
||||
lifecycle.onPerform();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
continue;
|
||||
}
|
||||
if ( counter == 2 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mEnableModuleName = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,8 +71,14 @@ public class FragmentStack {
|
||||
mFragmentTransaction.hide( mCurrentFragment.getFragment() );
|
||||
}
|
||||
mFragmentTransaction.add( mContainerId, descriptor.getFragment() );
|
||||
if ( descriptor.hasTransition() ) {
|
||||
mFragmentTransaction.setTransition( FragmentTransaction.TRANSIT_FRAGMENT_OPEN );
|
||||
}
|
||||
mFragmentTransaction.addToBackStack( null );
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
if ( descriptor.hasTransition() ) {
|
||||
mFragmentManager.executePendingTransactions();
|
||||
}
|
||||
mFragmentStack.push( descriptor );
|
||||
mCurrentFragment = descriptor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user