- changed loader to OmnipodUtil
- Modules
This commit is contained in:
parent
f3c4b4e5e7
commit
4f79b49e10
4 changed files with 34 additions and 14 deletions
|
@ -18,8 +18,6 @@ import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertAc
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
|
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
|
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
|
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
|
||||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
|
@ -50,7 +48,6 @@ abstract class ActivitiesModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
@ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
@ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
||||||
@ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity
|
|
||||||
@ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,6 +3,9 @@ package info.nightscout.androidaps.dependencyInjection
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
||||||
|
@ -11,9 +14,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class OmnipodModule {
|
abstract class OmnipodModule {
|
||||||
|
|
||||||
|
// Activities
|
||||||
|
@ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity
|
||||||
|
@ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
@ContributesAndroidInjector abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager
|
||||||
@ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask
|
@ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask
|
||||||
@ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager
|
@ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager
|
||||||
@ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction
|
@ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction
|
||||||
|
@ContributesAndroidInjector abstract fun podSessionState(): PodSessionState
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -619,15 +619,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
if (omnipodUtil.getPodSessionState() != null) {
|
if (omnipodUtil.getPodSessionState() != null) {
|
||||||
podSessionState = omnipodUtil.getPodSessionState();
|
podSessionState = omnipodUtil.getPodSessionState();
|
||||||
} else {
|
} else {
|
||||||
String podState = sp.getString(OmnipodConst.Prefs.PodState, "");
|
podSessionState = omnipodUtil.loadSessionState();
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(podState)) {
|
|
||||||
podSessionState = omnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
|
||||||
podSessionState.injectDaggerClass(injector);
|
|
||||||
omnipodUtil.setPodSessionState(podSessionState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
|
@ -15,10 +16,12 @@ import org.joda.time.format.ISODateTimeFormat;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
@ -46,6 +49,7 @@ public class OmnipodUtil {
|
||||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
private final OmnipodPumpStatus omnipodPumpStatus;
|
||||||
private final ActivePluginProvider activePlugins;
|
private final ActivePluginProvider activePlugins;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
private final HasAndroidInjector injector;
|
||||||
|
|
||||||
private boolean lowLevelDebug = true;
|
private boolean lowLevelDebug = true;
|
||||||
private OmnipodCommandType currentCommand;
|
private OmnipodCommandType currentCommand;
|
||||||
|
@ -63,7 +67,8 @@ public class OmnipodUtil {
|
||||||
RileyLinkUtil rileyLinkUtil,
|
RileyLinkUtil rileyLinkUtil,
|
||||||
OmnipodPumpStatus omnipodPumpStatus,
|
OmnipodPumpStatus omnipodPumpStatus,
|
||||||
SP sp,
|
SP sp,
|
||||||
ActivePluginProvider activePlugins
|
ActivePluginProvider activePlugins,
|
||||||
|
HasAndroidInjector injector
|
||||||
) {
|
) {
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
@ -71,6 +76,7 @@ public class OmnipodUtil {
|
||||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.activePlugins = activePlugins;
|
this.activePlugins = activePlugins;
|
||||||
|
this.injector = injector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,4 +229,20 @@ public class OmnipodUtil {
|
||||||
public SP getSp() {
|
public SP getSp() {
|
||||||
return this.sp;
|
return this.sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PodSessionState loadSessionState() {
|
||||||
|
String podState = sp.getString(OmnipodConst.Prefs.PodState, "");
|
||||||
|
|
||||||
|
aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(podState)) {
|
||||||
|
PodSessionState podSessionState = gsonInstance.fromJson(podState, PodSessionState.class);
|
||||||
|
podSessionState.injectDaggerClass(injector);
|
||||||
|
setPodSessionState(podSessionState);
|
||||||
|
|
||||||
|
return podSessionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue