Daggerize AapsOmnipodManager
This commit is contained in:
parent
0fef4128ef
commit
8f7ba93c47
|
@ -47,6 +47,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var podStateManager: PodStateManager
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||
@Inject lateinit var aapsOmnipodManager: AapsOmnipodManager
|
||||
|
||||
private var initPodChanged = false
|
||||
|
||||
|
@ -141,7 +142,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
fun resetPodAction() {
|
||||
OKDialog.showConfirmation(this,
|
||||
resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
|
||||
AapsOmnipodManager.getInstance().resetPodStatus()
|
||||
aapsOmnipodManager.resetPodStatus()
|
||||
refreshButtons()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodMa
|
|||
public class InitPodTask extends AsyncTask<Void, Void, String> {
|
||||
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject AapsOmnipodManager aapsOmnipodManager;
|
||||
private InitActionFragment initActionFragment;
|
||||
|
||||
public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) {
|
||||
|
@ -34,19 +35,19 @@ public class InitPodTask extends AsyncTask<Void, Void, String> {
|
|||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
if (initActionFragment.podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
|
||||
initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod(
|
||||
initActionFragment.callResult = aapsOmnipodManager.initPod(
|
||||
initActionFragment.podInitActionType,
|
||||
initActionFragment,
|
||||
null
|
||||
);
|
||||
} else if (initActionFragment.podInitActionType == PodInitActionType.FillCannulaSetBasalProfileWizardStep) {
|
||||
initActionFragment.callResult = AapsOmnipodManager.getInstance().initPod(
|
||||
initActionFragment.callResult = aapsOmnipodManager.initPod(
|
||||
initActionFragment.podInitActionType,
|
||||
initActionFragment,
|
||||
profileFunction.getProfile()
|
||||
);
|
||||
} else if (initActionFragment.podInitActionType == PodInitActionType.DeactivatePodWizardStep) {
|
||||
initActionFragment.callResult = AapsOmnipodManager.getInstance().deactivatePod(initActionFragment);
|
||||
initActionFragment.callResult = aapsOmnipodManager.deactivatePod(initActionFragment);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
|
|
|
@ -10,6 +10,9 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
|
@ -73,7 +76,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
// TODO make singleton
|
||||
@Singleton
|
||||
public class AapsOmnipodManager implements IOmnipodManager {
|
||||
|
||||
private final PodStateManager podStateManager;
|
||||
|
@ -87,15 +90,9 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
|||
private final Context context;
|
||||
|
||||
private final OmnipodManager delegate;
|
||||
|
||||
//TODO: remove and use injection
|
||||
private static AapsOmnipodManager instance;
|
||||
private DatabaseHelperInterface databaseHelper;
|
||||
|
||||
public static AapsOmnipodManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
|
||||
PodStateManager podStateManager,
|
||||
OmnipodPumpStatus pumpStatus,
|
||||
|
@ -123,7 +120,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
|||
this.databaseHelper = databaseHelper;
|
||||
|
||||
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podStateManager);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public PodStateManager getPodStateManager() {
|
||||
|
|
|
@ -43,11 +43,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
|
||||
@Inject PodStateManager podStateManager;
|
||||
@Inject DatabaseHelperInterface databaseHelper;
|
||||
|
||||
private static RileyLinkOmnipodService instance;
|
||||
|
||||
private OmnipodCommunicationManager omnipodCommunicationManager;
|
||||
private AapsOmnipodManager aapsOmnipodManager;
|
||||
@Inject AapsOmnipodManager aapsOmnipodManager;
|
||||
@Inject OmnipodCommunicationManager omnipodCommunicationManager;
|
||||
|
||||
private IBinder mBinder = new LocalBinder();
|
||||
private boolean rileyLinkAddressChanged = false;
|
||||
|
@ -57,11 +54,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
public RileyLinkOmnipodService() {
|
||||
super();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static RileyLinkOmnipodService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,18 +93,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
}
|
||||
|
||||
private void initializeErosOmnipodManager() {
|
||||
AapsOmnipodManager instance = AapsOmnipodManager.getInstance();
|
||||
if (instance == null) {
|
||||
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
|
||||
this.omnipodCommunicationManager = omnipodCommunicationService;
|
||||
|
||||
aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podStateManager, omnipodPumpStatus,
|
||||
omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin, this, databaseHelper);
|
||||
|
||||
if (omnipodUIComm == null) {
|
||||
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil);
|
||||
|
||||
} else {
|
||||
aapsOmnipodManager = instance;
|
||||
}
|
||||
rxBus.send(new EventOmnipodPumpValuesChanged());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue