This commit is contained in:
Milos Kozak 2017-09-05 22:47:37 +02:00
commit e3ae7bbeaf

View file

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