-initpodtask possible fix

This commit is contained in:
Andy Rozman 2020-05-08 12:20:29 +01:00
parent 9a36e9def8
commit 745b59cbed
2 changed files with 10 additions and 5 deletions

View file

@ -26,6 +26,8 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import dagger.android.support.DaggerFragment;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
@ -35,7 +37,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
/** /**
* Created by andy on 12/11/2019 * Created by andy on 12/11/2019
*/ */
public class InitActionFragment extends Fragment implements PodInitReceiver { public class InitActionFragment extends DaggerFragment implements PodInitReceiver {
private static final String ARG_KEY = "key"; private static final String ARG_KEY = "key";
protected PageFragmentCallbacks mCallbacks; protected PageFragmentCallbacks mCallbacks;
@ -53,6 +55,8 @@ public class InitActionFragment extends Fragment implements PodInitReceiver {
protected PumpEnactResult callResult; protected PumpEnactResult callResult;
@Inject HasAndroidInjector injector;
public static InitActionFragment create(String key, PodInitActionType podInitActionType) { public static InitActionFragment create(String key, PodInitActionType podInitActionType) {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -125,7 +129,7 @@ public class InitActionFragment extends Fragment implements PodInitReceiver {
} }
}); });
new InitPodTask(instance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new InitPodTask(injector, instance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}); });
return rootView; return rootView;
@ -165,7 +169,7 @@ public class InitActionFragment extends Fragment implements PodInitReceiver {
//System.out.println("ACTION: setUserVisibleHint="+ isVisibleToUser); //System.out.println("ACTION: setUserVisibleHint="+ isVisibleToUser);
if (isVisibleToUser) { if (isVisibleToUser) {
//System.out.println("ACTION: Visible"); //System.out.println("ACTION: Visible");
new InitPodTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new InitPodTask(injector, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else { } else {
System.out.println("ACTION: Not visible"); System.out.println("ACTION: Not visible");

View file

@ -6,6 +6,7 @@ import android.view.View;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
@ -18,8 +19,8 @@ public class InitPodTask extends AsyncTask<Void, Void, String> {
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
private InitActionFragment initActionFragment; private InitActionFragment initActionFragment;
public InitPodTask(InitActionFragment initActionFragment) { public InitPodTask(HasAndroidInjector injector, InitActionFragment initActionFragment) {
injector.androidInjector().inject(this);
this.initActionFragment = initActionFragment; this.initActionFragment = initActionFragment;
} }