Merge branch 'koreandanar' of https://github.com/MilosKozak/AndroidAPS into koreandanar
This commit is contained in:
commit
d72a3cbf36
2 changed files with 26 additions and 10 deletions
|
@ -39,8 +39,6 @@ import info.nightscout.utils.LocaleHelper;
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
||||||
|
|
||||||
private static KeepAliveReceiver keepAliveReceiver;
|
|
||||||
|
|
||||||
static final int CASE_STORAGE = 0x1;
|
static final int CASE_STORAGE = 0x1;
|
||||||
static final int CASE_SMS = 0x2;
|
static final int CASE_SMS = 0x2;
|
||||||
|
|
||||||
|
@ -77,11 +75,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
// no action
|
// no action
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keepAliveReceiver == null) {
|
|
||||||
keepAliveReceiver = new KeepAliveReceiver();
|
|
||||||
startService(new Intent(this, ExecutionService.class));
|
|
||||||
keepAliveReceiver.setAlarm(this);
|
|
||||||
}
|
|
||||||
setUpTabs(false);
|
setUpTabs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +163,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
// break;
|
// break;
|
||||||
case R.id.nav_exit:
|
case R.id.nav_exit:
|
||||||
log.debug("Exiting");
|
log.debug("Exiting");
|
||||||
keepAliveReceiver.cancelAlarm(this);
|
MainApp.instance().stopKeepAliveService();
|
||||||
|
|
||||||
MainApp.bus().post(new EventAppExit());
|
MainApp.bus().post(new EventAppExit());
|
||||||
MainApp.closeDbHelper();
|
MainApp.closeDbHelper();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -37,11 +38,13 @@ import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
||||||
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
|
|
||||||
public class MainApp extends Application {
|
public class MainApp extends Application {
|
||||||
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
||||||
|
private static KeepAliveReceiver keepAliveReceiver;
|
||||||
|
|
||||||
private static Bus sBus;
|
private static Bus sBus;
|
||||||
private static MainApp sInstance;
|
private static MainApp sInstance;
|
||||||
|
@ -94,6 +97,26 @@ public class MainApp extends Application {
|
||||||
MainApp.getConfigBuilder().initialize();
|
MainApp.getConfigBuilder().initialize();
|
||||||
}
|
}
|
||||||
MainApp.getConfigBuilder().uploadAppStart();
|
MainApp.getConfigBuilder().uploadAppStart();
|
||||||
|
|
||||||
|
startKeepAliveService();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startKeepAliveService() {
|
||||||
|
if (keepAliveReceiver == null) {
|
||||||
|
keepAliveReceiver = new KeepAliveReceiver();
|
||||||
|
if (Config.DANAR) {
|
||||||
|
startService(new Intent(this, info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService.class));
|
||||||
|
startService(new Intent(this, info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService.class));
|
||||||
|
}
|
||||||
|
keepAliveReceiver.setAlarm(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void stopKeepAliveService(){
|
||||||
|
if(keepAliveReceiver!=null)
|
||||||
|
keepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
public static Bus bus() {
|
||||||
|
@ -172,4 +195,4 @@ public class MainApp extends Application {
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
sDatabaseHelper.close();
|
sDatabaseHelper.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue