2016-06-05 01:40:35 +02:00
|
|
|
package info.nightscout.androidaps;
|
|
|
|
|
|
|
|
import android.app.Application;
|
2016-12-16 02:00:53 +01:00
|
|
|
import android.content.Intent;
|
2017-07-24 01:50:27 +02:00
|
|
|
import android.content.IntentFilter;
|
2016-06-24 17:16:17 +02:00
|
|
|
import android.content.res.Resources;
|
2016-07-18 20:19:55 +02:00
|
|
|
import android.support.annotation.Nullable;
|
2017-07-24 01:50:27 +02:00
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2016-06-24 17:48:11 +02:00
|
|
|
import com.crashlytics.android.Crashlytics;
|
2017-03-02 23:08:40 +01:00
|
|
|
import com.crashlytics.android.answers.Answers;
|
2017-03-02 23:25:55 +01:00
|
|
|
import com.crashlytics.android.answers.CustomEvent;
|
2016-06-05 01:40:35 +02:00
|
|
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
|
|
|
import com.squareup.otto.Bus;
|
|
|
|
import com.squareup.otto.ThreadEnforcer;
|
|
|
|
|
2016-08-05 23:54:03 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
import info.nightscout.androidaps.Services.Intents;
|
2016-08-05 23:54:03 +02:00
|
|
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
2017-05-12 17:57:57 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
2016-07-18 20:19:55 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
2017-03-24 23:03:55 +01:00
|
|
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
2016-11-05 15:46:11 +01:00
|
|
|
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
2016-07-18 20:19:55 +02:00
|
|
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
2017-05-23 23:56:53 +02:00
|
|
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
|
2017-06-24 13:22:50 +02:00
|
|
|
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
2017-05-23 23:56:53 +02:00
|
|
|
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment;
|
2017-04-21 15:36:49 +02:00
|
|
|
import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment;
|
2017-08-14 13:20:09 +02:00
|
|
|
import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefFreePeakFragment;
|
2017-08-14 11:44:34 +02:00
|
|
|
import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefRapidActingFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefUltraRapidActingFragment;
|
2017-06-24 13:22:50 +02:00
|
|
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
2017-05-23 23:56:53 +02:00
|
|
|
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
2017-07-24 02:33:29 +02:00
|
|
|
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
2017-05-23 23:56:53 +02:00
|
|
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
|
2017-04-21 12:15:08 +02:00
|
|
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
2017-05-23 23:56:53 +02:00
|
|
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
|
|
|
|
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
|
2017-05-24 18:24:23 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpCombo.ComboFragment;
|
2017-04-21 12:15:08 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
2017-04-30 21:08:00 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
2017-04-21 12:15:08 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanFragment;
|
2017-04-30 21:08:00 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Fragment;
|
|
|
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
2017-06-24 13:22:50 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
2017-06-07 18:10:07 +02:00
|
|
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
2017-06-30 11:56:36 +02:00
|
|
|
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
2017-06-24 11:04:09 +02:00
|
|
|
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
2017-07-07 15:08:21 +02:00
|
|
|
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
2016-07-18 20:19:55 +02:00
|
|
|
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
|
2017-06-24 13:22:50 +02:00
|
|
|
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
|
|
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
2017-05-25 17:26:05 +02:00
|
|
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
2016-11-17 16:38:58 +01:00
|
|
|
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
2017-06-24 13:22:50 +02:00
|
|
|
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
2017-07-24 01:50:27 +02:00
|
|
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
2016-12-16 02:00:53 +01:00
|
|
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
2017-07-24 02:27:16 +02:00
|
|
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
2017-05-26 08:54:48 +02:00
|
|
|
import info.nightscout.utils.NSUpload;
|
2016-06-24 17:48:11 +02:00
|
|
|
import io.fabric.sdk.android.Fabric;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
|
|
|
|
2016-08-05 23:54:03 +02:00
|
|
|
public class MainApp extends Application {
|
2016-06-05 01:40:35 +02:00
|
|
|
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
2016-12-16 02:00:53 +01:00
|
|
|
private static KeepAliveReceiver keepAliveReceiver;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
|
|
|
private static Bus sBus;
|
|
|
|
private static MainApp sInstance;
|
2016-07-07 10:34:20 +02:00
|
|
|
public static Resources sResources;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2016-07-07 10:34:20 +02:00
|
|
|
private static DatabaseHelper sDatabaseHelper = null;
|
2016-08-05 23:54:03 +02:00
|
|
|
private static ConfigBuilderPlugin sConfigBuilder = null;
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
private static ArrayList<PluginBase> pluginsList = null;
|
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
private static DataReceiver dataReceiver = new DataReceiver();
|
2017-07-24 02:27:16 +02:00
|
|
|
private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
|
2017-07-24 02:33:29 +02:00
|
|
|
private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
|
2017-07-24 01:50:27 +02:00
|
|
|
private LocalBroadcastManager lbm;
|
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2016-06-24 17:48:11 +02:00
|
|
|
Fabric.with(this, new Crashlytics());
|
2017-03-02 23:08:40 +01:00
|
|
|
Fabric.with(this, new Answers());
|
2016-11-08 19:10:25 +01:00
|
|
|
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
|
|
|
|
log.info("Version: " + BuildConfig.VERSION_NAME);
|
|
|
|
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
2016-06-05 01:40:35 +02:00
|
|
|
|
2017-03-02 23:25:55 +01:00
|
|
|
Answers.getInstance().logCustom(new CustomEvent("AppStart"));
|
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
sBus = new Bus(ThreadEnforcer.ANY);
|
|
|
|
sInstance = this;
|
2016-07-07 10:34:20 +02:00
|
|
|
sResources = getResources();
|
2016-07-18 20:19:55 +02:00
|
|
|
|
2017-07-24 01:50:27 +02:00
|
|
|
registerLocalBroadcastReceiver();
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
if (pluginsList == null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
pluginsList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
// Register all tabs in app here
|
2016-08-05 23:54:03 +02:00
|
|
|
pluginsList.add(OverviewFragment.getPlugin());
|
2017-06-24 13:22:50 +02:00
|
|
|
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
2017-02-23 20:00:33 +01:00
|
|
|
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
2017-04-21 11:45:25 +02:00
|
|
|
pluginsList.add(InsulinFastactingFragment.getPlugin());
|
2017-04-21 15:36:49 +02:00
|
|
|
pluginsList.add(InsulinFastactingProlongedFragment.getPlugin());
|
2017-08-14 11:44:34 +02:00
|
|
|
pluginsList.add(InsulinOrefRapidActingFragment.getPlugin());
|
|
|
|
pluginsList.add(InsulinOrefUltraRapidActingFragment.getPlugin());
|
2017-08-14 13:20:09 +02:00
|
|
|
pluginsList.add(InsulinOrefFreePeakFragment.getPlugin());
|
2017-06-24 11:04:09 +02:00
|
|
|
pluginsList.add(SensitivityOref0Plugin.getPlugin());
|
2017-06-30 11:56:36 +02:00
|
|
|
pluginsList.add(SensitivityAAPSPlugin.getPlugin());
|
2017-07-07 15:08:21 +02:00
|
|
|
pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin());
|
2016-08-05 23:54:03 +02:00
|
|
|
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
2017-04-30 21:08:00 +02:00
|
|
|
if (Config.DANAR) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
2017-05-10 21:58:46 +02:00
|
|
|
if (Config.DANARv2) pluginsList.add(DanaRv2Fragment.getPlugin());
|
2017-05-24 18:24:23 +02:00
|
|
|
if (Config.COMBO) pluginsList.add(ComboFragment.getPlugin());
|
2017-02-23 20:00:33 +01:00
|
|
|
pluginsList.add(CareportalFragment.getPlugin());
|
2017-06-24 13:22:50 +02:00
|
|
|
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
2017-06-07 18:10:07 +02:00
|
|
|
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
2016-08-05 23:54:03 +02:00
|
|
|
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
|
2017-01-03 21:01:01 +01:00
|
|
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
|
2017-01-03 21:15:40 +01:00
|
|
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());
|
2016-12-24 23:53:17 +01:00
|
|
|
pluginsList.add(NSProfileFragment.getPlugin());
|
2017-02-23 20:00:33 +01:00
|
|
|
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
|
|
|
|
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
|
2017-04-25 16:37:27 +02:00
|
|
|
if (Config.OTHERPROFILES)
|
|
|
|
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
2017-05-25 17:26:05 +02:00
|
|
|
pluginsList.add(TreatmentsFragment.getPlugin());
|
2017-06-24 13:22:50 +02:00
|
|
|
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
2016-08-05 23:54:03 +02:00
|
|
|
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
|
2017-06-04 00:46:44 +02:00
|
|
|
if (!Config.NSCLIENT)
|
2017-06-24 13:22:50 +02:00
|
|
|
pluginsList.add(SourceXdripPlugin.getPlugin());
|
|
|
|
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
2017-06-04 00:46:44 +02:00
|
|
|
if (!Config.NSCLIENT)
|
2017-06-24 13:22:50 +02:00
|
|
|
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
2017-06-04 00:46:44 +02:00
|
|
|
if (!Config.NSCLIENT)
|
2017-06-24 13:22:50 +02:00
|
|
|
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
2017-02-23 20:00:33 +01:00
|
|
|
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
|
2016-11-17 16:38:58 +01:00
|
|
|
|
2016-11-26 05:31:23 +01:00
|
|
|
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
2017-06-24 13:22:50 +02:00
|
|
|
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
2016-12-28 00:03:08 +01:00
|
|
|
pluginsList.add(new PersistentNotificationPlugin(this));
|
2017-02-17 13:18:36 +01:00
|
|
|
pluginsList.add(NSClientInternalFragment.getPlugin());
|
2016-11-17 16:38:58 +01:00
|
|
|
|
2016-08-05 23:54:03 +02:00
|
|
|
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());
|
2016-07-18 20:19:55 +02:00
|
|
|
|
|
|
|
MainApp.getConfigBuilder().initialize();
|
|
|
|
}
|
2017-05-26 08:54:48 +02:00
|
|
|
NSUpload.uploadAppStart();
|
2016-12-16 02:00:53 +01:00
|
|
|
|
|
|
|
startKeepAliveService();
|
2017-03-24 23:03:55 +01:00
|
|
|
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
Thread.sleep(5000);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
}
|
|
|
|
PumpInterface pump = MainApp.getConfigBuilder();
|
|
|
|
if (pump != null)
|
|
|
|
pump.refreshDataFromPump("Initialization");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
t.start();
|
2017-07-24 01:50:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void registerLocalBroadcastReceiver() {
|
|
|
|
lbm = LocalBroadcastManager.getInstance(this);
|
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
|
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
|
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
|
2017-07-24 01:55:01 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
|
2017-07-24 01:58:23 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
|
2017-07-24 02:00:46 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS));
|
2017-07-24 02:02:54 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG));
|
2017-07-24 02:06:05 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_DEVICESTATUS));
|
2017-07-24 02:09:26 +02:00
|
|
|
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
|
|
|
|
|
2017-07-24 02:27:16 +02:00
|
|
|
//register alarms
|
|
|
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ALARM));
|
|
|
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ANNOUNCEMENT));
|
|
|
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
|
|
|
|
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
|
|
|
|
|
|
|
|
//register ack alarm
|
2017-07-24 02:33:29 +02:00
|
|
|
lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
|
2016-12-16 02:00:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void startKeepAliveService() {
|
|
|
|
if (keepAliveReceiver == null) {
|
|
|
|
keepAliveReceiver = new KeepAliveReceiver();
|
|
|
|
if (Config.DANAR) {
|
2017-04-30 21:08:00 +02:00
|
|
|
startService(new Intent(this, DanaRExecutionService.class));
|
|
|
|
startService(new Intent(this, DanaRKoreanExecutionService.class));
|
|
|
|
startService(new Intent(this, DanaRv2ExecutionService.class));
|
2016-12-16 02:00:53 +01:00
|
|
|
}
|
|
|
|
keepAliveReceiver.setAlarm(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-25 16:37:27 +02:00
|
|
|
public void stopKeepAliveService() {
|
|
|
|
if (keepAliveReceiver != null)
|
|
|
|
keepAliveReceiver.cancelAlarm(this);
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Bus bus() {
|
|
|
|
return sBus;
|
|
|
|
}
|
2016-08-05 23:54:03 +02:00
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
public static MainApp instance() {
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DatabaseHelper getDbHelper() {
|
2016-07-07 10:34:20 +02:00
|
|
|
if (sDatabaseHelper == null) {
|
|
|
|
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
2016-07-07 10:34:20 +02:00
|
|
|
return sDatabaseHelper;
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void closeDbHelper() {
|
2016-07-07 10:34:20 +02:00
|
|
|
if (sDatabaseHelper != null) {
|
|
|
|
sDatabaseHelper.close();
|
|
|
|
sDatabaseHelper = null;
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-05 23:54:03 +02:00
|
|
|
public static ConfigBuilderPlugin getConfigBuilder() {
|
2016-07-07 10:34:20 +02:00
|
|
|
return sConfigBuilder;
|
2016-06-21 23:24:54 +02:00
|
|
|
}
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
public static ArrayList<PluginBase> getPluginsList() {
|
|
|
|
return pluginsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsList(int type) {
|
2016-08-05 23:54:03 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
|
|
|
|
if (pluginsList != null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : pluginsList) {
|
2016-07-18 20:19:55 +02:00
|
|
|
if (p.getType() == type)
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:57:57 +02:00
|
|
|
@Nullable
|
|
|
|
public static InsulinInterface getInsulinIterfaceById(int id) {
|
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (pluginsList != null) {
|
|
|
|
for (PluginBase p : pluginsList) {
|
2017-05-23 23:56:53 +02:00
|
|
|
if (p.getType() == PluginBase.INSULIN && ((InsulinInterface) p).getId() == id)
|
2017-05-12 17:57:57 +02:00
|
|
|
return (InsulinInterface) p;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("InsulinInterface not found");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-04-29 16:59:44 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(int type) {
|
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (pluginsList != null) {
|
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getType() == type)
|
|
|
|
if (p.showInList(type))
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) {
|
2016-08-05 23:54:03 +02:00
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
2016-07-18 20:19:55 +02:00
|
|
|
|
|
|
|
if (pluginsList != null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getClass() != ConfigBuilderPlugin.class && interfaceClass.isAssignableFrom(p.getClass()))
|
2016-07-18 20:19:55 +02:00
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2017-04-29 16:59:44 +02:00
|
|
|
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, int type) {
|
|
|
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (pluginsList != null) {
|
|
|
|
for (PluginBase p : pluginsList) {
|
|
|
|
if (p.getClass() != ConfigBuilderPlugin.class && interfaceClass.isAssignableFrom(p.getClass()))
|
|
|
|
if (p.showInList(type))
|
|
|
|
newList.add(p);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return newList;
|
|
|
|
}
|
|
|
|
|
2016-07-18 20:19:55 +02:00
|
|
|
@Nullable
|
|
|
|
public static PluginBase getSpecificPlugin(Class pluginClass) {
|
|
|
|
if (pluginsList != null) {
|
2016-08-05 23:54:03 +02:00
|
|
|
for (PluginBase p : pluginsList) {
|
2016-07-18 20:19:55 +02:00
|
|
|
if (p.getClass() == pluginClass)
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.error("pluginsList=null");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-06-05 01:40:35 +02:00
|
|
|
@Override
|
|
|
|
public void onTerminate() {
|
|
|
|
super.onTerminate();
|
2016-07-07 10:34:20 +02:00
|
|
|
sDatabaseHelper.close();
|
2016-06-05 01:40:35 +02:00
|
|
|
}
|
2016-12-16 02:00:53 +01:00
|
|
|
}
|