Fix comparing non-primitives.

This commit is contained in:
Johannes Mockenhaupt 2017-08-20 10:52:06 +02:00
parent 30372897c0
commit 56423028f6
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 12 additions and 7 deletions

View file

@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.ConstraintsSafety;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
@ -161,17 +163,17 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
Double origRate = absoluteRate;
if (absoluteRate > maxBasal) {
absoluteRate = maxBasal;
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
log.debug("Limiting rate " + origRate + " by maxBasal preference to " + absoluteRate + "U/h");
}
if (absoluteRate > maxBasalMult * profile.getBasal()) {
absoluteRate = Math.floor(maxBasalMult * profile.getBasal() * 100) / 100;
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
log.debug("Limiting rate " + origRate + " by maxBasalMult to " + absoluteRate + "U/h");
}
if (absoluteRate > profile.getMaxDailyBasal() * maxBasalFromDaily) {
absoluteRate = profile.getMaxDailyBasal() * maxBasalFromDaily;
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
log.debug("Limiting rate " + origRate + " by 3 * maxDailyBasal to " + absoluteRate + "U/h");
}
@ -180,7 +182,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, 10d).intValue();
else percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, 10d).intValue();
if (Config.logConstraintsChanges && origPercentRate != Constants.basalPercentOnlyForCheckLimit)
if (Config.logConstraintsChanges && !Objects.equals(origPercentRate, Constants.basalPercentOnlyForCheckLimit))
log.debug("Recalculated percent rate " + percentRate + "% to " + percentRateAfterConst + "%");
return percentRateAfterConst;
}

View file

@ -6,6 +6,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
import java.util.Objects;
/*
{
@ -188,7 +189,7 @@ public class NSSettingsStatus {
return result;
}
}
if (settingsO.has("alarmTimeagoWarnMins") && what == "alarmTimeagoWarnMins"){
if (settingsO.has("alarmTimeagoWarnMins") && Objects.equals(what, "alarmTimeagoWarnMins")){
Double result = settingsO.getDouble(what);
return result;
}

View file

@ -20,6 +20,7 @@ import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import java.text.DecimalFormat;
import java.util.Objects;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
@ -86,7 +87,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
if (insulinAfterConstraints - insulin != 0 || carbsAfterConstraints != carbs)
if (insulinAfterConstraints - insulin != 0 || !Objects.equals(carbsAfterConstraints, carbs))
confirmMessage += "\n" + getString(R.string.constraintapllied);
final double finalInsulinAfterConstraints = insulinAfterConstraints;

View file

@ -55,6 +55,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@ -1740,7 +1741,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
Notification notification = notificationsList.get(position);
holder.dismiss.setTag(notification);
if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata))
if(Objects.equals(notification.text, MainApp.sResources.getString(R.string.nsalarm_staledata)))
holder.dismiss.setText("snooze");
holder.text.setText(notification.text);
holder.time.setText(DateUtil.timeString(notification.date));