allow removing temp target records with null _id
This commit is contained in:
parent
f9ed2ed4b4
commit
9f4cc28c0f
1 changed files with 22 additions and 22 deletions
|
@ -128,14 +128,15 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
final Context finalContext = context;
|
final Context finalContext = context;
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.temptargetrange_remove:
|
case R.id.temptargetrange_remove:
|
||||||
final String _id = tempTarget._id;
|
|
||||||
if (_id != null && !_id.equals("")) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + _id);
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.timeStart));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
final String _id = tempTarget._id;
|
||||||
|
if (_id != null && !_id.equals("")) {
|
||||||
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
daoTempTargets.delete(tempTarget);
|
daoTempTargets.delete(tempTarget);
|
||||||
|
@ -147,7 +148,6 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,8 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
case R.id.temptargetrange_refreshfromnightscout:
|
case R.id.temptargetrange_refreshfromnightscout:
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
|
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
|
||||||
if(nsUploadOnly){
|
if (nsUploadOnly) {
|
||||||
ToastUtils.showToastInUiThread(getContext(),this.getContext().getString(R.string.ns_upload_only_enabled));
|
ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled));
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||||
|
|
Loading…
Reference in a new issue