Use OK/Cancel buttons for 'profile changes refresh from NS' dialog in Treatments tab.

This commit is contained in:
Johannes Mockenhaupt 2017-09-03 01:50:27 +02:00
parent 737c1f4e0b
commit 3bebea37ae
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -6,7 +6,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
@ -28,14 +27,11 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.utils.OKDialog;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
@ -61,8 +57,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
@Override @Override
public ProfileSwitchViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { public ProfileSwitchViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_profileswitch_item, viewGroup, false); View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_profileswitch_item, viewGroup, false);
ProfileSwitchViewHolder ProfileSwitchViewHolder = new ProfileSwitchViewHolder(v); return new ProfileSwitchViewHolder(v);
return ProfileSwitchViewHolder;
} }
@Override @Override
@ -187,14 +182,18 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.profileswitch_refreshfromnightscout: case R.id.profileswitch_refreshfromnightscout:
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.confirmation), MainApp.sResources.getString(R.string.refresheventsfromnightscout) + "?", new Runnable() { AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
@Override builder.setTitle(this.getContext().getString(R.string.confirmation));
public void run() { builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?");
builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MainApp.getDbHelper().resetProfileSwitch(); MainApp.getDbHelper().resetProfileSwitch();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART); Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
} }
}); });
builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
builder.show();
break; break;
} }
} }