notify card accOn when acc on
This commit is contained in:
@@ -125,6 +125,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient.start();
|
||||
|
||||
mMogoModuleHandler.loadPushService();
|
||||
|
||||
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@ public interface MogoModulesHandler extends IMogoMapListener,
|
||||
*/
|
||||
void setEnable( String module );
|
||||
|
||||
/**
|
||||
* 加载 push 服务
|
||||
*/
|
||||
void loadPushService();
|
||||
|
||||
/**
|
||||
* 销毁
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@@ -18,6 +21,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.main.MainActivity;
|
||||
import com.mogo.module.main.receiver.MogoReceiver;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
@@ -49,11 +53,14 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
private String mEnableModuleName = null;
|
||||
private Runnable mMapLoadedCallback;
|
||||
|
||||
private BroadcastReceiver mReceiver;
|
||||
|
||||
public MogoModulesManager( MainActivity activity ) {
|
||||
if ( activity == null ) {
|
||||
throw new NullPointerException( "activity can't be null." );
|
||||
}
|
||||
this.mActivity = activity;
|
||||
registerReceiver();
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
@@ -128,6 +135,16 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadPushService() {
|
||||
IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance().build( "" ).navigation( mActivity.getApplicationContext() );
|
||||
if ( provider != null ) {
|
||||
if ( provider.getType() == IMogoModuleProvider.TYPE_SERVICE ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnable( String module ) {
|
||||
mEnableModuleName = module;
|
||||
@@ -277,8 +294,45 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
}
|
||||
}
|
||||
|
||||
public void registerReceiver() {
|
||||
mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
final String action = intent.getAction();
|
||||
if ( TextUtils.equals( action, Intent.ACTION_POWER_CONNECTED ) ) {
|
||||
for ( IMogoModuleProvider value : mCardProviders.values() ) {
|
||||
if ( value.getCardLifecycle() != null ) {
|
||||
value.getCardLifecycle().accOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( TextUtils.equals( action, Intent.ACTION_POWER_DISCONNECTED ) ) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
IntentFilter inputFilter = new IntentFilter();
|
||||
inputFilter.addAction( Intent.ACTION_POWER_CONNECTED );
|
||||
inputFilter.addAction( Intent.ACTION_POWER_DISCONNECTED );
|
||||
getApplicationContext().registerReceiver( mReceiver, inputFilter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
if ( mReceiver != null ) {
|
||||
try {
|
||||
getApplicationContext().unregisterReceiver( mReceiver );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
mReceiver = null;
|
||||
mActivity = null;
|
||||
if ( mCardProviders != null ) {
|
||||
mCardProviders.clear();
|
||||
}
|
||||
mMapProvider = null;
|
||||
mAppsListProvider = null;
|
||||
mMapLoadedCallback = null;
|
||||
mEnableModuleName = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.module.main.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-02
|
||||
* <p>
|
||||
* 广播接收者
|
||||
* <p>
|
||||
* {@link Intent#ACTION_POWER_CONNECTED}
|
||||
* {@link Intent#ACTION_POWER_DISCONNECTED}
|
||||
*/
|
||||
public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static void register( Context context ) {
|
||||
if ( context == null ) {
|
||||
return;
|
||||
}
|
||||
IntentFilter inputFilter = new IntentFilter();
|
||||
inputFilter.addAction( Intent.ACTION_POWER_CONNECTED );
|
||||
inputFilter.addAction( Intent.ACTION_POWER_DISCONNECTED );
|
||||
context.getApplicationContext().registerReceiver( new MogoReceiver(), inputFilter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent ) {
|
||||
final String action = intent.getAction();
|
||||
if ( TextUtils.equals( action, Intent.ACTION_POWER_CONNECTED ) ) {
|
||||
|
||||
}
|
||||
if ( TextUtils.equals( action, Intent.ACTION_POWER_DISCONNECTED ) ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user