bolus progress dialog without activity context

This commit is contained in:
AdrianLxM 2017-02-09 03:15:13 +01:00
parent 74107f58fe
commit bf7a96b3e7
5 changed files with 53 additions and 0 deletions

View file

@ -33,6 +33,7 @@
</intent-filter>
</activity>
<activity android:name=".PreferencesActivity" />
<activity android:name=".plugins.Overview.Dialogs.BolusProgressHelperActivity" android:theme="@style/Theme.AppCompat.Translucent" />
<activity android:name=".AgreementActivity" />
<activity android:name=".plugins.DanaR.History.DanaRHistoryActivity" />
<activity android:name=".plugins.DanaRKorean.History.DanaRHistoryActivity" />

View file

@ -46,6 +46,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@ -470,6 +471,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin);
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
} else {
Intent i = new Intent();
i.putExtra("insulin", insulin.doubleValue());
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
MainApp.bus().post(new EventBolusRequested(insulin));

View file

@ -29,6 +29,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
TextView statusView;
TextView stopPressedView;
ProgressBar progressBar;
BolusProgressHelperActivity helperActivity;
static double amount;
public static boolean bolusEnded = false;
@ -45,6 +46,10 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
bolusEnded = false;
}
public void setHelperActivity(BolusProgressHelperActivity activity){
this.helperActivity = activity;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -71,6 +76,14 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
if (bolusEnded) dismiss();
}
@Override
public void dismiss(){
super.dismiss();
if (helperActivity!= null){
helperActivity.finish();
}
}
@Override
public void onPause() {
super.onPause();

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
/**
* Created by adrian on 09/02/17.
*/
public class BolusProgressHelperActivity extends AppCompatActivity {
public BolusProgressHelperActivity() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getIntent().getDoubleExtra("insulin", 0d);
BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setHelperActivity(this);
bolusProgressDialog.setInsulin(this.getIntent().getDoubleExtra("insulin", 0d));
bolusProgressDialog.show(this.getSupportFragmentManager(), "BolusProgress");
}
}

View file

@ -14,4 +14,12 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>
</resources>