use System.currentTimeMillis()

This commit is contained in:
Milos Kozak 2017-06-15 23:12:12 +02:00
parent 26daffa692
commit 43231cc362
61 changed files with 212 additions and 213 deletions

View file

@ -514,7 +514,7 @@ public class DataService extends IntentService {
if (trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) { if (trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
long date = trJson.getLong("mills"); long date = trJson.getLong("mills");
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (date > now - 15 * 60 * 1000L && trJson.has("notes")) { if (date > now - 15 * 60 * 1000L && trJson.has("notes")) {
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, trJson.getString("notes"), Notification.ANNOUNCEMENT, 60); Notification announcement = new Notification(Notification.NSANNOUNCEMENT, trJson.getString("notes"), Notification.ANNOUNCEMENT, 60);
MainApp.bus().post(new EventNewNotification(announcement)); MainApp.bus().post(new EventNewNotification(announcement));

View file

@ -16,7 +16,7 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
*/ */
public class DetailedBolusInfo { public class DetailedBolusInfo {
public long date = new Date().getTime(); public long date = System.currentTimeMillis();
public InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin(); public InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin();
public String eventType = CareportalEvent.MEALBOLUS; public String eventType = CareportalEvent.MEALBOLUS;
public double insulin = 0; public double insulin = 0;

View file

@ -67,11 +67,11 @@ public class GlucoseStatus {
@Nullable @Nullable
public static GlucoseStatus getGlucoseStatusData() { public static GlucoseStatus getGlucoseStatusData() {
// load 45min // load 45min
long fromtime = (long) (new Date().getTime() - 60 * 1000L * 45); long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
int sizeRecords = data.size(); int sizeRecords = data.size();
if (sizeRecords < 1 || data.get(0).date < new Date().getTime() - 7 * 60 * 1000L) { if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) {
return null; return null;
} }

View file

@ -215,7 +215,7 @@ public class Profile {
} }
public Double getIsf() { public Double getIsf() {
return getIsf(secondsFromMidnight(new Date().getTime())); return getIsf(secondsFromMidnight(System.currentTimeMillis()));
} }
public Double getIsf(long time) { public Double getIsf(long time) {
@ -233,7 +233,7 @@ public class Profile {
} }
public Double getIc() { public Double getIc() {
return getIc(secondsFromMidnight(new Date().getTime())); return getIc(secondsFromMidnight(System.currentTimeMillis()));
} }
public Double getIc(long time) { public Double getIc(long time) {
@ -251,7 +251,7 @@ public class Profile {
} }
public Double getBasal() { public Double getBasal() {
return getBasal(secondsFromMidnight(new Date().getTime())); return getBasal(secondsFromMidnight(System.currentTimeMillis()));
} }
public Double getBasal(long time) { public Double getBasal(long time) {
@ -296,7 +296,7 @@ public class Profile {
} }
public Double getTargetLow() { public Double getTargetLow() {
return getTargetLow(secondsFromMidnight(new Date().getTime())); return getTargetLow(secondsFromMidnight(System.currentTimeMillis()));
} }
public Double getTargetLow(long time) { public Double getTargetLow(long time) {
@ -308,7 +308,7 @@ public class Profile {
} }
public Double getTargetHigh() { public Double getTargetHigh() {
return getTargetHigh(secondsFromMidnight(new Date().getTime())); return getTargetHigh(secondsFromMidnight(System.currentTimeMillis()));
} }
public Double getTargetHigh(long time) { public Double getTargetHigh(long time) {

View file

@ -81,15 +81,15 @@ public class CareportalEvent implements DataPointWithLabelInterface {
} }
public long getMillisecondsFromStart() { public long getMillisecondsFromStart() {
return new Date().getTime() - date; return System.currentTimeMillis() - date;
} }
public long getHoursFromStart() { public long getHoursFromStart() {
return (new Date().getTime() - date) / (60 * 1000); return (System.currentTimeMillis() - date) / (60 * 1000);
} }
public String age() { public String age() {
Map<TimeUnit, Long> diff = computeDiff(date, new Date().getTime()); Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours); return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
} }

View file

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@ -142,35 +141,35 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void cleanUpDatabases() { public void cleanUpDatabases() {
// TODO: call it somewhere // TODO: call it somewhere
log.debug("Before BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS)); log.debug("Before BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
getWritableDatabase().delete(DATABASE_BGREADINGS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_BGREADINGS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
log.debug("After BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS)); log.debug("After BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
log.debug("Before TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS)); log.debug("Before TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
getWritableDatabase().delete(DATABASE_TEMPTARGETS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_TEMPTARGETS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
log.debug("After TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS)); log.debug("After TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
log.debug("Before Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS)); log.debug("Before Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
getWritableDatabase().delete(DATABASE_TREATMENTS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_TREATMENTS, "date" + " < '" + (System.currentTimeMillis() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
log.debug("After Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS)); log.debug("After Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
log.debug("Before History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY)); log.debug("Before History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
getWritableDatabase().delete(DATABASE_DANARHISTORY, "recordDate" + " < '" + (new Date().getTime() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_DANARHISTORY, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
log.debug("After History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY)); log.debug("After History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
log.debug("Before TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS)); log.debug("Before TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS));
getWritableDatabase().delete(DATABASE_TEMPORARYBASALS, "recordDate" + " < '" + (new Date().getTime() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_TEMPORARYBASALS, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
log.debug("After TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS)); log.debug("After TemporaryBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPORARYBASALS));
log.debug("Before ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES)); log.debug("Before ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES));
getWritableDatabase().delete(DATABASE_EXTENDEDBOLUSES, "recordDate" + " < '" + (new Date().getTime() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_EXTENDEDBOLUSES, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
log.debug("After ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES)); log.debug("After ExtendedBoluses size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_EXTENDEDBOLUSES));
log.debug("Before CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS)); log.debug("Before CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS));
getWritableDatabase().delete(DATABASE_CAREPORTALEVENTS, "recordDate" + " < '" + (new Date().getTime() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_CAREPORTALEVENTS, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
log.debug("After CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS)); log.debug("After CareportalEvent size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_CAREPORTALEVENTS));
log.debug("Before ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES)); log.debug("Before ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES));
getWritableDatabase().delete(DATABASE_PROFILESWITCHES, "recordDate" + " < '" + (new Date().getTime() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null); getWritableDatabase().delete(DATABASE_PROFILESWITCHES, "recordDate" + " < '" + (System.currentTimeMillis() - Constants.daysToKeepHistoryInDatabase * 24 * 60 * 60 * 1000L) + "'", null);
log.debug("After ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES)); log.debug("After ProfileSwitch size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_PROFILESWITCHES));
} }
@ -406,7 +405,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (lastBg == null) if (lastBg == null)
return null; return null;
if (lastBg.date > new Date().getTime() - 9 * 60 * 1000) if (lastBg.date > System.currentTimeMillis() - 9 * 60 * 1000)
return lastBg; return lastBg;
return null; return null;

View file

@ -139,7 +139,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
@Override @Override
public boolean isInProgress() { public boolean isInProgress() {
return match(new Date().getTime()); return match(System.currentTimeMillis());
} }
@Override @Override
@ -202,7 +202,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
} }
public int getRealDuration() { public int getRealDuration() {
return getDurationToTime(new Date().getTime()); return getDurationToTime(System.currentTimeMillis());
} }
private int getDurationToTime(long time) { private int getDurationToTime(long time) {
@ -212,7 +212,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
} }
public int getPlannedRemainingMinutes() { public int getPlannedRemainingMinutes() {
float remainingMin = (end() - new Date().getTime()) / 1000f / 60; float remainingMin = (end() - System.currentTimeMillis()) / 1000f / 60;
return (remainingMin < 0) ? 0 : Math.round(remainingMin); return (remainingMin < 0) ? 0 : Math.round(remainingMin);
} }

View file

@ -148,7 +148,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
@Override @Override
public boolean isInProgress() { public boolean isInProgress() {
return match(new Date().getTime()); return match(System.currentTimeMillis());
} }
@Override @Override

View file

@ -115,7 +115,7 @@ public class TempTarget implements Interval {
@Override @Override
public boolean isInProgress() { public boolean isInProgress() {
return match(new Date().getTime()); return match(System.currentTimeMillis());
} }
@Override @Override

View file

@ -159,7 +159,7 @@ public class TemporaryBasal implements Interval {
@Override @Override
public boolean isInProgress() { public boolean isInProgress() {
return match(new Date().getTime()); return match(System.currentTimeMillis());
} }
@Override @Override
@ -222,7 +222,7 @@ public class TemporaryBasal implements Interval {
} }
public int getRealDuration() { public int getRealDuration() {
return getDurationToTime(new Date().getTime()); return getDurationToTime(System.currentTimeMillis());
} }
private int getDurationToTime(long time) { private int getDurationToTime(long time) {
@ -232,7 +232,7 @@ public class TemporaryBasal implements Interval {
} }
public int getPlannedRemainingMinutes() { public int getPlannedRemainingMinutes() {
float remainingMin = (end() - new Date().getTime()) / 1000f / 60; float remainingMin = (end() - System.currentTimeMillis()) / 1000f / 60;
return (remainingMin < 0) ? 0 : Math.round(remainingMin); return (remainingMin < 0) ? 0 : Math.round(remainingMin);
} }

View file

@ -71,7 +71,7 @@ public class Treatment implements DataPointWithLabelInterface {
} }
public long getMillisecondsFromStart() { public long getMillisecondsFromStart() {
return new Date().getTime() - date; return System.currentTimeMillis() - date;
} }
public String toString() { public String toString() {

View file

@ -143,7 +143,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
extendedBolusCancel.setVisibility(View.GONE); extendedBolusCancel.setVisibility(View.GONE);
else { else {
extendedBolusCancel.setVisibility(View.VISIBLE); extendedBolusCancel.setVisibility(View.VISIBLE);
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString()); extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
} }
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress()) if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress())

View file

@ -617,7 +617,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
try { try {
String profileName = data.getString("profile"); String profileName = data.getString("profile");
ProfileSwitch profileSwitch = new ProfileSwitch(); ProfileSwitch profileSwitch = new ProfileSwitch();
profileSwitch.date = new Date().getTime(); profileSwitch.date = System.currentTimeMillis();
profileSwitch.source = Source.USER; profileSwitch.source = Source.USER;
profileSwitch.profileName = profileName; profileSwitch.profileName = profileName;
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString(); profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();

View file

@ -437,7 +437,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
t.insulin = result.bolusDelivered; t.insulin = result.bolusDelivered;
if (carbTime == 0) if (carbTime == 0)
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
t.date = new Date().getTime(); t.date = System.currentTimeMillis();
t.mealBolus = result.carbsDelivered > 0; t.mealBolus = result.carbsDelivered > 0;
addToHistoryTreatment(t); addToHistoryTreatment(t);
t.carbs = (double) result.carbsDelivered; t.carbs = (double) result.carbsDelivered;
@ -512,7 +512,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
Treatment t = new Treatment(insulinType); Treatment t = new Treatment(insulinType);
t.insulin = result.bolusDelivered; t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered; t.carbs = (double) result.carbsDelivered;
t.date = new Date().getTime(); t.date = System.currentTimeMillis();
t.mealBolus = t.carbs > 0; t.mealBolus = t.carbs > 0;
addToHistoryTreatment(t); addToHistoryTreatment(t);
NSUpload.uploadTreatment(t); NSUpload.uploadTreatment(t);
@ -633,7 +633,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < 0.05) { } else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < 0.05) {
result = new PumpEnactResult(); result = new PumpEnactResult();
result.absolute = getTempBasalAbsoluteRateHistory(); result.absolute = getTempBasalAbsoluteRateHistory();
result.duration = getTempBasalFromHistory(new Date().getTime()).getPlannedRemainingMinutes(); result.duration = getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes();
result.enacted = false; result.enacted = false;
result.comment = "Temp basal set correctly"; result.comment = "Temp basal set correctly";
result.success = true; result.success = true;
@ -982,7 +982,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
public String getProfileName() { public String getProfileName() {
return getProfileName(new Date().getTime()); return getProfileName(System.currentTimeMillis());
} }
public String getProfileName(long time) { public String getProfileName(long time) {
@ -1005,7 +1005,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
public Profile getProfile() { public Profile getProfile() {
return getProfile(new Date().getTime()); return getProfile(System.currentTimeMillis());
} }
public String getProfileUnits() { public String getProfileUnits() {

View file

@ -91,7 +91,7 @@ public class ObjectivesFragment extends Fragment {
} }
}); });
Long now = new Date().getTime(); Long now = System.currentTimeMillis();
if (position > 0 && objectives.get(position - 1).accomplished.getTime() == 0) { if (position > 0 && objectives.get(position - 1).accomplished.getTime() == 0) {
// Phase 0: previous not completed // Phase 0: previous not completed
holder.startedLayout.setVisibility(View.GONE); holder.startedLayout.setVisibility(View.GONE);

View file

@ -22,7 +22,7 @@ public class AutosensData {
} }
public int minOld() { public int minOld() {
return (int) ((new Date().getTime() - time) / 1000 / 60); return (int) ((System.currentTimeMillis() - time) / 1000 / 60);
} }
} }

View file

@ -158,7 +158,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
//log.debug("Locking loadBgData"); //log.debug("Locking loadBgData");
synchronized (dataLock) { synchronized (dataLock) {
onNewProfile(null); onNewProfile(null);
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)), false); bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)), false);
log.debug("BG data loaded. Size: " + bgReadings.size()); log.debug("BG data loaded. Size: " + bgReadings.size());
} }
//log.debug("Releasing loadBgData"); //log.debug("Releasing loadBgData");
@ -393,7 +393,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
} }
public static IobTotal calulateFromTreatmentsAndTemps(long time) { public static IobTotal calulateFromTreatmentsAndTemps(long time) {
long now = new Date().getTime(); long now = System.currentTimeMillis();
time = roundUpTime(time); time = roundUpTime(time);
if (time < now && iobTable.get(time) != null) { if (time < now && iobTable.get(time) != null) {
//og.debug(">>> calulateFromTreatmentsAndTemps Cache hit " + new Date(time).toLocaleString()); //og.debug(">>> calulateFromTreatmentsAndTemps Cache hit " + new Date(time).toLocaleString());
@ -405,7 +405,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
IobTotal basalIob = MainApp.getConfigBuilder().getCalculationToTimeTempBasals(time).round(); IobTotal basalIob = MainApp.getConfigBuilder().getCalculationToTimeTempBasals(time).round();
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
if (time < new Date().getTime()) { if (time < System.currentTimeMillis()) {
iobTable.put(time, iobTotal); iobTable.put(time, iobTotal);
} }
return iobTotal; return iobTotal;
@ -423,7 +423,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
} }
public static BasalData getBasalData(long time) { public static BasalData getBasalData(long time) {
long now = new Date().getTime(); long now = System.currentTimeMillis();
time = roundUpTime(time); time = roundUpTime(time);
BasalData retval = basalDataTable.get(time); BasalData retval = basalDataTable.get(time);
if (retval == null) { if (retval == null) {
@ -448,7 +448,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
} }
public static AutosensData getAutosensData(long time) { public static AutosensData getAutosensData(long time) {
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (time > now) if (time > now)
return null; return null;
Long previous = findPreviousTimeFromBucketedData(time); Long previous = findPreviousTimeFromBucketedData(time);
@ -469,7 +469,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
if (autosensDataTable.size() < 1) if (autosensDataTable.size() < 1)
return null; return null;
AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1); AutosensData data = autosensDataTable.valueAt(autosensDataTable.size() - 1);
if (data.time < new Date().getTime() - 5 * 60 * 1000) { if (data.time < System.currentTimeMillis() - 5 * 60 * 1000) {
return null; return null;
} else { } else {
return data; return data;
@ -479,7 +479,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
public static IobTotal[] calculateIobArrayInDia() { public static IobTotal[] calculateIobArrayInDia() {
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
// predict IOB out to DIA plus 30m // predict IOB out to DIA plus 30m
long time = new Date().getTime(); long time = System.currentTimeMillis();
time = roundUpTime(time); time = roundUpTime(time);
int len = (int) ((profile.getDia() * 60 + 30) / 5); int len = (int) ((profile.getDia() * 60 + 30) / 5);
IobTotal[] array = new IobTotal[len]; IobTotal[] array = new IobTotal[len];

View file

@ -167,7 +167,7 @@ public class LoopPlugin implements PluginBase {
if (loopSuspendedTill == 0) if (loopSuspendedTill == 0)
return 0; return 0;
long now = new Date().getTime(); long now = System.currentTimeMillis();
long msecDiff = loopSuspendedTill - now; long msecDiff = loopSuspendedTill - now;
if (loopSuspendedTill <= now) { // time exceeded if (loopSuspendedTill <= now) { // time exceeded
@ -182,7 +182,7 @@ public class LoopPlugin implements PluginBase {
if (loopSuspendedTill == 0) if (loopSuspendedTill == 0)
return false; return false;
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (loopSuspendedTill <= now) { // time exceeded if (loopSuspendedTill <= now) { // time exceeded
suspendTo(0L); suspendTo(0L);
@ -196,7 +196,7 @@ public class LoopPlugin implements PluginBase {
if (loopSuspendedTill == 0) if (loopSuspendedTill == 0)
return false; return false;
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (loopSuspendedTill <= now) { // time exceeded if (loopSuspendedTill <= now) { // time exceeded
suspendTo(0L); suspendTo(0L);

View file

@ -63,7 +63,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
data = new JSONObject(); data = new JSONObject();
} }
// mark by id // mark by id
Long nsclientid = new Date().getTime(); Long nsclientid = System.currentTimeMillis();
try { try {
data.put("NSCLIENT_ID", nsclientid); data.put("NSCLIENT_ID", nsclientid);
} catch (JSONException e) { } catch (JSONException e) {

View file

@ -484,7 +484,7 @@ public class NSClientService extends Service {
// remove from upload queue if Ack is failing // remove from upload queue if Ack is failing
UploadQueue.removeID(jsonTreatment); UploadQueue.removeID(jsonTreatment);
//Find latest date in treatment //Find latest date in treatment
if (treatment.getMills() != null && treatment.getMills() < new Date().getTime()) if (treatment.getMills() != null && treatment.getMills() < System.currentTimeMillis())
if (treatment.getMills() > latestDateInReceivedData) if (treatment.getMills() > latestDateInReceivedData)
latestDateInReceivedData = treatment.getMills(); latestDateInReceivedData = treatment.getMills();
@ -493,7 +493,7 @@ public class NSClientService extends Service {
} else if (treatment.getAction().equals("update")) { } else if (treatment.getAction().equals("update")) {
updatedTreatments.put(jsonTreatment); updatedTreatments.put(jsonTreatment);
} else if (treatment.getAction().equals("remove")) { } else if (treatment.getAction().equals("remove")) {
if (treatment.getMills() != null && treatment.getMills() > new Date().getTime() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only if (treatment.getMills() != null && treatment.getMills() > System.currentTimeMillis() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only
removedTreatments.put(jsonTreatment); removedTreatments.put(jsonTreatment);
} }
} }
@ -554,7 +554,7 @@ public class NSClientService extends Service {
// remove from upload queue if Ack is failing // remove from upload queue if Ack is failing
UploadQueue.removeID(jsonSgv); UploadQueue.removeID(jsonSgv);
//Find latest date in sgv //Find latest date in sgv
if (sgv.getMills() != null && sgv.getMills() < new Date().getTime()) if (sgv.getMills() != null && sgv.getMills() < System.currentTimeMillis())
if (sgv.getMills() > latestDateInReceivedData) if (sgv.getMills() > latestDateInReceivedData)
latestDateInReceivedData = sgv.getMills(); latestDateInReceivedData = sgv.getMills();
} }
@ -676,11 +676,11 @@ public class NSClientService extends Service {
public void run() { public void run() {
if (mSocket == null || !mSocket.connected()) return; if (mSocket == null || !mSocket.connected()) return;
if (lastResendTime > new Date().getTime() - 10 * 1000L) { if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
log.debug("Skipping resend by lastResendTime: " + ((new Date().getTime() - lastResendTime) / 1000L) + " sec"); log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
return; return;
} }
lastResendTime = new Date().getTime(); lastResendTime = System.currentTimeMillis();
MainApp.bus().post(new EventNSClientNewLog("QUEUE", "Resend started: " + reason)); MainApp.bus().post(new EventNSClientNewLog("QUEUE", "Resend started: " + reason));

View file

@ -232,7 +232,7 @@ public class DetermineBasalAdapterAMAJS {
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()); mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory());
// as we have non default temps longer than 30 mintues // as we have non default temps longer than 30 mintues
TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (tempBasal != null) { if (tempBasal != null) {
mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration()); mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration());
} }

View file

@ -187,7 +187,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]); targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
boolean isTempTarget = false; boolean isTempTarget = false;
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
if (tempTarget != null) { if (tempTarget != null) {
isTempTarget = true; isTempTarget = true;
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
@ -208,7 +208,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return; if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable(); long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))); long getBGDataFrom = Math.max(oldestDataAvailable, (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + profile.getDia())));
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString()); log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
startPart = new Date(); startPart = new Date();

View file

@ -186,7 +186,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
maxBg = verifyHardLimits(maxBg, "maxBg", Constants.VERY_HARD_LIMIT_MAX_BG[0], Constants.VERY_HARD_LIMIT_MAX_BG[1]); maxBg = verifyHardLimits(maxBg, "maxBg", Constants.VERY_HARD_LIMIT_MAX_BG[0], Constants.VERY_HARD_LIMIT_MAX_BG[1]);
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]); targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
if (tempTarget != null) { if (tempTarget != null) {
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
maxBg = verifyHardLimits(tempTarget.high, "maxBg", Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]); maxBg = verifyHardLimits(tempTarget.high, "maxBg", Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);

View file

@ -148,7 +148,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) { if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE); cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true; cobAvailable = true;
} else { } else {
@ -317,7 +317,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (useSuperBolus) { if (useSuperBolus) {
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if (activeloop != null) { if (activeloop != null) {
activeloop.superBolusTo(new Date().getTime() + 2 * 60L * 60 * 1000); activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshGui(false));
} }
result = pump.setTempBasalAbsolute(0d, 120); result = pump.setTempBasalAbsolute(0d, 120);
@ -422,7 +422,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE); wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
// COB only if AMA is selected // COB only if AMA is selected
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) { if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
cobLayout.setVisibility(View.VISIBLE); cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true; cobAvailable = true;
} else { } else {
@ -466,7 +466,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
// COB // COB
Double c_cob = 0d; Double c_cob = 0d;
if (cobAvailable && cobCheckbox.isChecked()) { if (cobAvailable && cobCheckbox.isChecked()) {
if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(new Date().getTime() - 11 * 60 * 1000L))) { if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
try { try {
c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB")); c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB"));
} catch (JSONException e) { } catch (JSONException e) {

View file

@ -61,7 +61,7 @@ public class Notification {
this.date = new Date(); this.date = new Date();
this.text = text; this.text = text;
this.level = level; this.level = level;
this.validTo = new Date(new Date().getTime() + validMinutes * 60 * 1000L); this.validTo = new Date(System.currentTimeMillis() + validMinutes * 60 * 1000L);
} }
public Notification(int id, String text, int level) { public Notification(int id, String text, int level) {
@ -81,7 +81,7 @@ public class Notification {
this.id = NSANNOUNCEMENT; this.id = NSANNOUNCEMENT;
this.level = ANNOUNCEMENT; this.level = ANNOUNCEMENT;
this.text = nsAlarm.getMessage(); this.text = nsAlarm.getMessage();
this.validTo = new Date(new Date().getTime() + 60 * 60 * 1000L); this.validTo = new Date(System.currentTimeMillis() + 60 * 60 * 1000L);
break; break;
case 1: case 1:
this.id = NSALARM; this.id = NSALARM;

View file

@ -57,7 +57,7 @@ public class NotificationStore {
public void removeExpired() { public void removeExpired() {
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
Notification n = get(i); Notification n = get(i);
if (n.validTo.getTime() != 0 && n.validTo.getTime() < new Date().getTime()) { if (n.validTo.getTime() != 0 && n.validTo.getTime() < System.currentTimeMillis()) {
store.remove(i); store.remove(i);
i--; i--;
} }

View file

@ -430,7 +430,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(0); NSUpload.uploadOpenAPSOffline(0);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
activeloop.suspendTo(new Date().getTime() + 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -444,7 +444,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(60); NSUpload.uploadOpenAPSOffline(60);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -458,7 +458,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(120); NSUpload.uploadOpenAPSOffline(120);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -472,7 +472,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(180); NSUpload.uploadOpenAPSOffline(180);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
activeloop.suspendTo(new Date().getTime() + 10 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 10 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -486,7 +486,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(600); NSUpload.uploadOpenAPSOffline(600);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
activeloop.suspendTo(new Date().getTime() + 30L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -500,7 +500,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(30); NSUpload.uploadOpenAPSOffline(30);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
activeloop.suspendTo(new Date().getTime() + 1 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -514,7 +514,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(60); NSUpload.uploadOpenAPSOffline(60);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -528,7 +528,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(120); NSUpload.uploadOpenAPSOffline(120);
return true; return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) { } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000); activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
updateGUI("suspendmenu"); updateGUI("suspendmenu");
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
@ -953,7 +953,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
// temp target // temp target
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
if (tempTarget != null) { if (tempTarget != null) {
tempTargetView.setTextColor(Color.BLACK); tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
@ -998,7 +998,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
calibrationButton.setVisibility(View.GONE); calibrationButton.setVisibility(View.GONE);
} }
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) { if (activeTemp != null) {
cancelTempButton.setVisibility(View.VISIBLE); cancelTempButton.setVisibility(View.VISIBLE);
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort()); cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
@ -1017,7 +1017,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
baseBasalView.setText(basalText); baseBasalView.setText(basalText);
ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
String extendedBolusText = ""; String extendedBolusText = "";
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) { if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
extendedBolusText = extendedBolus.toString(); extendedBolusText = extendedBolus.toString();
@ -1121,7 +1121,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
flag &= ~Paint.STRIKE_THRU_TEXT_FLAG; flag &= ~Paint.STRIKE_THRU_TEXT_FLAG;
bgView.setPaintFlags(flag); bgView.setPaintFlags(flag);
Long agoMsec = new Date().getTime() - lastBG.date; Long agoMsec = System.currentTimeMillis() - lastBG.date;
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin)); timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
@ -1139,7 +1139,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// cob // cob
if (cobView != null) { // view must not exists if (cobView != null) { // view must not exists
String cobText = ""; String cobText = "";
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(new Date().getTime()); AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
if (autosensData != null) if (autosensData != null)
cobText = (int) autosensData.cob + " g " + String.format(MainApp.sResources.getString(R.string.minago), autosensData.minOld()); cobText = (int) autosensData.cob + " g " + String.format(MainApp.sResources.getString(R.string.minago), autosensData.minOld());
cobView.setText(cobText); cobView.setText(cobText);
@ -1159,7 +1159,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// allign to hours // allign to hours
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(new Date().getTime()); calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.MINUTE, 0);
@ -1170,7 +1170,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
long fromTime; long fromTime;
long endTime; long endTime;
if (showPrediction) { if (showPrediction) {
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - new Date().getTime()) / (60 * 60 * 1000)); int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
predHours = Math.min(2, predHours); predHours = Math.min(2, predHours);
predHours = Math.max(0, predHours); predHours = Math.max(0, predHours);
hoursToFetch = rangeToDisplay - predHours; hoursToFetch = rangeToDisplay - predHours;
@ -1194,7 +1194,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** TEMP BASALS graph **** // **** TEMP BASALS graph ****
Double maxBasalValueFound = 0d; Double maxBasalValueFound = 0d;
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) { if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
List<DataPoint> baseBasalArray = new ArrayList<>(); List<DataPoint> baseBasalArray = new ArrayList<>();
List<DataPoint> tempBasalArray = new ArrayList<>(); List<DataPoint> tempBasalArray = new ArrayList<>();

View file

@ -139,7 +139,7 @@ public class PersistentNotificationPlugin implements PluginBase {
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
line1 += " " + activeTemp.toStringShort(); line1 += " " + activeTemp.toStringShort();
} }

View file

@ -213,13 +213,13 @@ public class DanaRFragment extends Fragment {
public void run() { public void run() {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")"); lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d); SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
} }
if (pump.lastBolusTime.getTime() != 0) { if (pump.lastBolusTime.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d; double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U"); lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
@ -230,12 +230,12 @@ public class DanaRFragment extends Fragment {
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h"); basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h");
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toStringFull()); tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }

View file

@ -309,7 +309,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = new Date().getTime(); detailedBolusInfo.date = System.currentTimeMillis();
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
return result; return result;
} else { } else {
@ -336,7 +336,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
@Override @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
// Recheck pump status if older than 30 min // Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data"); doConnect("setTempBasalAbsolute old data");
} }
@ -393,7 +393,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ? // Correct basal already set ?
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) { if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
result.success = true; result.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
@ -644,7 +644,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
@Override @Override
public JSONObject getJSONStatus() { public JSONObject getJSONStatus() {
if (pump.lastConnection.getTime() + 5 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 5 * 60 * 1000L < System.currentTimeMillis()) {
return null; return null;
} }
JSONObject pumpjson = new JSONObject(); JSONObject pumpjson = new JSONObject();
@ -661,13 +661,13 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -805,7 +805,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
public String shortStatus(boolean veryShort) { public String shortStatus(boolean veryShort) {
String ret = ""; String ret = "";
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
ret += "LastConn: " + agoMin + " minago\n"; ret += "LastConn: " + agoMin + " minago\n";
} }
@ -813,10 +813,10 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toStringFull() + "\n"; ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -30,13 +30,13 @@ public class MsgBolusProgress extends MessageBase {
this(); this();
this.amount = amount; this.amount = amount;
this.t = t; this.t = t;
lastReceive = new Date().getTime(); lastReceive = System.currentTimeMillis();
} }
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
progress = intFromBuff(bytes, 0, 2); progress = intFromBuff(bytes, 0, 2);
lastReceive = new Date().getTime(); lastReceive = System.currentTimeMillis();
Double done = (amount * 100 - progress) / 100d; Double done = (amount * 100 - progress) / 100d;
t.insulin = done; t.insulin = done;
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();

View file

@ -61,16 +61,16 @@ public class MsgStatusBolusExtended extends MessageBase {
@NonNull @NonNull
private Date getDateFromSecAgo(int tempBasalAgoSecs) { private Date getDateFromSecAgo(int tempBasalAgoSecs) {
return new Date((long) (Math.ceil(new Date().getTime() / 1000d) - tempBasalAgoSecs) * 1000); return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
} }
public static void updateExtendedBolusInDB() { public static void updateExtendedBolusInDB() {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) { if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(System.currentTimeMillis());
if (pump.isExtendedInProgress) { if (pump.isExtendedInProgress) {
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) { if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
// Close current extended // Close current extended

View file

@ -55,16 +55,16 @@ public class MsgStatusTempBasal extends MessageBase {
@NonNull @NonNull
private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) { private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
return new Date((long) (Math.ceil(new Date().getTime() / 1000d) - tempBasalAgoSecs) * 1000); return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
} }
public static void updateTempBasalInDB() { public static void updateTempBasalInDB() {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
DanaRPump danaRPump = DanaRPump.getInstance(); DanaRPump danaRPump = DanaRPump.getInstance();
long now = new Date().getTime(); long now = System.currentTimeMillis();
if (treatmentsInterface.isInHistoryRealTempBasalInProgress()) { if (treatmentsInterface.isInHistoryRealTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasalFromHistory(new Date().getTime()); TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasalFromHistory(System.currentTimeMillis());
if (danaRPump.isTempBasalInProgress) { if (danaRPump.isTempBasalInProgress) {
if (tempBasal.percentRate != danaRPump.tempBasalPercent) { if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
// Close current temp basal // Close current temp basal

View file

@ -200,9 +200,9 @@ public class DanaRExecutionService extends Service {
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) if (mRfcommSocket == null || mBTDevice == null)
return; // Device not found return; // Device not found
long startTime = new Date().getTime(); long startTime = System.currentTimeMillis();
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) { while (!isConnected() && startTime + maxConnectionTime >= System.currentTimeMillis()) {
long secondsElapsed = (new Date().getTime() - startTime) / 1000L; long secondsElapsed = (System.currentTimeMillis() - startTime) / 1000L;
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
if (Config.logDanaBTComm) if (Config.logDanaBTComm)
log.debug("connect waiting " + secondsElapsed + "sec from: " + from); log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
@ -229,7 +229,7 @@ public class DanaRExecutionService extends Service {
if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP)) if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP))
return; return;
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
startTime = new Date().getTime(); startTime = System.currentTimeMillis();
} }
} }
} }
@ -404,12 +404,12 @@ public class DanaRExecutionService extends Service {
if (!isConnected()) return false; if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(new Date().getTime(), carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
} }
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MainApp.bus().post(new EventDanaRBolusStart()); MainApp.bus().post(new EventDanaRBolusStart());
long startTime = new Date().getTime(); long startTime = System.currentTimeMillis();
if (!stop.stopped) { if (!stop.stopped) {
mSerialIOThread.sendMessage(start); mSerialIOThread.sendMessage(start);
@ -419,7 +419,7 @@ public class DanaRExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); waitMsec(100);
if ((new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm
stop.stopped = true; stop.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");
@ -430,7 +430,7 @@ public class DanaRExecutionService extends Service {
// try to find real amount if bolusing was interrupted or comm failed // try to find real amount if bolusing was interrupted or comm failed
if (t.insulin != amount) { if (t.insulin != amount) {
disconnect("bolusingInterrupted"); disconnect("bolusingInterrupted");
long now = new Date().getTime(); long now = System.currentTimeMillis();
long estimatedBolusEnd = (long) (startTime + amount / 5d * 60 * 1000); // std delivery rate 5 U/min long estimatedBolusEnd = (long) (startTime + amount / 5d * 60 * 1000); // std delivery rate 5 U/min
waitMsec(Math.max(5000, estimatedBolusEnd - now + 3000)); waitMsec(Math.max(5000, estimatedBolusEnd - now + 3000));
connect("bolusingInterrupted"); connect("bolusingInterrupted");
@ -466,7 +466,7 @@ public class DanaRExecutionService extends Service {
public boolean carbsEntry(int amount) { public boolean carbsEntry(int amount) {
connect("carbsEntry"); connect("carbsEntry");
if (!isConnected()) return false; if (!isConnected()) return false;
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(new Date().getTime(), amount); MsgSetCarbsEntry msg = new MsgSetCarbsEntry(System.currentTimeMillis(), amount);
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);
return true; return true;
} }

View file

@ -212,13 +212,13 @@ public class DanaRKoreanFragment extends Fragment {
public void run() { public void run() {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")"); lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d); SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
} }
// if (pump.lastBolusTime.getTime() != 0) { // if (pump.lastBolusTime.getTime() != 0) {
// Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime(); // Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
// double agoHours = agoMsec / 60d / 60d / 1000d; // double agoHours = agoMsec / 60d / 60d / 1000d;
// if (agoHours < 6) // max 6h back // if (agoHours < 6) // max 6h back
// lastBolusView.setText(formatTime.format(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + " U"); // lastBolusView.setText(formatTime.format(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + " U");
@ -229,12 +229,12 @@ public class DanaRKoreanFragment extends Fragment {
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h"); basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h");
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toStringFull()); tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }

View file

@ -313,7 +313,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
detailedBolusInfo.date = new Date().getTime(); detailedBolusInfo.date = System.currentTimeMillis();
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
return result; return result;
} else { } else {
@ -340,7 +340,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
@Override @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
// Recheck pump status if older than 30 min // Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data"); doConnect("setTempBasalAbsolute old data");
} }
@ -397,7 +397,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ? // Correct basal already set ?
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) { if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
result.success = true; result.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
@ -648,7 +648,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
@Override @Override
public JSONObject getJSONStatus() { public JSONObject getJSONStatus() {
if (pump.lastConnection.getTime() + 5 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 5 * 60 * 1000L < System.currentTimeMillis()) {
return null; return null;
} }
JSONObject pumpjson = new JSONObject(); JSONObject pumpjson = new JSONObject();
@ -665,13 +665,13 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -809,7 +809,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
public String shortStatus(boolean veryShort) { public String shortStatus(boolean veryShort) {
String ret = ""; String ret = "";
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
ret += "LastConn: " + agoMin + " minago\n"; ret += "LastConn: " + agoMin + " minago\n";
} }
@ -817,10 +817,10 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toStringFull() + "\n"; ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -196,9 +196,9 @@ public class DanaRKoreanExecutionService extends Service {
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) if (mRfcommSocket == null || mBTDevice == null)
return; // Device not found return; // Device not found
long startTime = new Date().getTime(); long startTime = System.currentTimeMillis();
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) { while (!isConnected() && startTime + maxConnectionTime >= System.currentTimeMillis()) {
long secondsElapsed = (new Date().getTime() - startTime) / 1000L; long secondsElapsed = (System.currentTimeMillis() - startTime) / 1000L;
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
if (Config.logDanaBTComm) if (Config.logDanaBTComm)
log.debug("connect waiting " + secondsElapsed + "sec from: " + from); log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
@ -225,7 +225,7 @@ public class DanaRKoreanExecutionService extends Service {
if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP)) if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP))
return; return;
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
startTime = new Date().getTime(); startTime = System.currentTimeMillis();
} }
} }
} }
@ -398,7 +398,7 @@ public class DanaRKoreanExecutionService extends Service {
if (!isConnected()) return false; if (!isConnected()) return false;
if (carbs > 0) { if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(new Date().getTime(), carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
} }
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
@ -412,7 +412,7 @@ public class DanaRKoreanExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); waitMsec(100);
if ((new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm
stop.stopped = true; stop.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");
@ -443,7 +443,7 @@ public class DanaRKoreanExecutionService extends Service {
public boolean carbsEntry(int amount) { public boolean carbsEntry(int amount) {
connect("carbsEntry"); connect("carbsEntry");
if (!isConnected()) return false; if (!isConnected()) return false;
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(new Date().getTime(), amount); MsgSetCarbsEntry msg = new MsgSetCarbsEntry(System.currentTimeMillis(), amount);
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);
return true; return true;
} }

View file

@ -210,13 +210,13 @@ public class DanaRv2Fragment extends Fragment {
public void run() { public void run() {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")"); lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d); SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
} }
if (pump.lastBolusTime.getTime() != 0) { if (pump.lastBolusTime.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d; double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U"); lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
@ -227,12 +227,12 @@ public class DanaRv2Fragment extends Fragment {
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h"); basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toStringFull()); tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }

View file

@ -289,7 +289,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
Treatment t = new Treatment(detailedBolusInfo.insulinInterface); Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, new Date().getTime() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, System.currentTimeMillis() + detailedBolusInfo.carbTime * 60 * 1000 + 1000, t); // +1000 to make the record different
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK; result.success = connectionOK;
result.bolusDelivered = t.insulin; result.bolusDelivered = t.insulin;
@ -322,7 +322,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
@Override @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
// Recheck pump status if older than 30 min // Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data"); doConnect("setTempBasalAbsolute old data");
} }
@ -361,7 +361,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ? // Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) { if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
result.success = true; result.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
@ -570,7 +570,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
@Override @Override
public JSONObject getJSONStatus() { public JSONObject getJSONStatus() {
if (pump.lastConnection.getTime() + 5 * 60 * 1000L < new Date().getTime()) { if (pump.lastConnection.getTime() + 5 * 60 * 1000L < System.currentTimeMillis()) {
return null; return null;
} }
JSONObject pumpjson = new JSONObject(); JSONObject pumpjson = new JSONObject();
@ -587,13 +587,13 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -731,7 +731,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
public String shortStatus(boolean veryShort) { public String shortStatus(boolean veryShort) {
String ret = ""; String ret = "";
if (pump.lastConnection.getTime() != 0) { if (pump.lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime(); Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime();
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
ret += "LastConn: " + agoMin + " minago\n"; ret += "LastConn: " + agoMin + " minago\n";
} }
@ -739,10 +739,10 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toStringFull() + "\n"; ret += "Temp: " + MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -59,7 +59,7 @@ public class MsgStatusBolusExtended_v2 extends MessageBase {
@NonNull @NonNull
private Date getDateFromSecAgo(int tempBasalAgoSecs) { private Date getDateFromSecAgo(int tempBasalAgoSecs) {
return new Date((long) (Math.ceil(new Date().getTime() / 1000d) - tempBasalAgoSecs) * 1000); return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
} }
} }

View file

@ -53,7 +53,7 @@ public class MsgStatusTempBasal_v2 extends MessageBase {
@NonNull @NonNull
private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) { private Date getDateFromTempBasalSecAgo(int tempBasalAgoSecs) {
return new Date((long) (Math.ceil(new Date().getTime() / 1000d) - tempBasalAgoSecs) * 1000); return new Date((long) (Math.ceil(System.currentTimeMillis() / 1000d) - tempBasalAgoSecs) * 1000);
} }
} }

View file

@ -171,9 +171,9 @@ public class DanaRv2ExecutionService extends Service {
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
if (mRfcommSocket == null || mBTDevice == null) if (mRfcommSocket == null || mBTDevice == null)
return; // Device not found return; // Device not found
long startTime = new Date().getTime(); long startTime = System.currentTimeMillis();
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) { while (!isConnected() && startTime + maxConnectionTime >= System.currentTimeMillis()) {
long secondsElapsed = (new Date().getTime() - startTime) / 1000L; long secondsElapsed = (System.currentTimeMillis() - startTime) / 1000L;
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
if (Config.logDanaBTComm) if (Config.logDanaBTComm)
log.debug("connect waiting " + secondsElapsed + "sec from: " + from); log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
@ -200,7 +200,7 @@ public class DanaRv2ExecutionService extends Service {
if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginBase.PUMP)) if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginBase.PUMP))
return; return;
getBTSocketForSelectedPump(); getBTSocketForSelectedPump();
startTime = new Date().getTime(); startTime = System.currentTimeMillis();
} }
} }
} }
@ -415,7 +415,7 @@ public class DanaRv2ExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); waitMsec(100);
if ((new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm
stop.stopped = true; stop.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");

View file

@ -89,12 +89,12 @@ public class VirtualPumpFragment extends Fragment {
basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U"); basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toStringFull()); tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString());
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }

View file

@ -256,7 +256,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) { public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
TemporaryBasal tempBasal = new TemporaryBasal(); TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = new Date().getTime(); tempBasal.date = System.currentTimeMillis();
tempBasal.isAbsolute = true; tempBasal.isAbsolute = true;
tempBasal.absoluteRate = absoluteRate; tempBasal.absoluteRate = absoluteRate;
tempBasal.durationInMinutes = durationInMinutes; tempBasal.durationInMinutes = durationInMinutes;
@ -286,7 +286,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return result; return result;
} }
TemporaryBasal tempBasal = new TemporaryBasal(); TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = new Date().getTime(); tempBasal.date = System.currentTimeMillis();
tempBasal.isAbsolute = false; tempBasal.isAbsolute = false;
tempBasal.percentRate = percent; tempBasal.percentRate = percent;
tempBasal.durationInMinutes = durationInMinutes; tempBasal.durationInMinutes = durationInMinutes;
@ -313,7 +313,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
if (!result.success) if (!result.success)
return result; return result;
ExtendedBolus extendedBolus = new ExtendedBolus(); ExtendedBolus extendedBolus = new ExtendedBolus();
extendedBolus.date = new Date().getTime(); extendedBolus.date = System.currentTimeMillis();
extendedBolus.insulin = insulin; extendedBolus.insulin = insulin;
extendedBolus.durationInMinutes = durationInMinutes; extendedBolus.durationInMinutes = durationInMinutes;
extendedBolus.source = Source.USER; extendedBolus.source = Source.USER;
@ -340,7 +340,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
if (treatmentsInterface.isTempBasalInProgress()) { if (treatmentsInterface.isTempBasalInProgress()) {
result.enacted = true; result.enacted = true;
TemporaryBasal tempStop = new TemporaryBasal(new Date().getTime()); TemporaryBasal tempStop = new TemporaryBasal(System.currentTimeMillis());
tempStop.source = Source.USER; tempStop.source = Source.USER;
treatmentsInterface.addToHistoryTempBasal(tempStop); treatmentsInterface.addToHistoryTempBasal(tempStop);
//tempBasal = null; //tempBasal = null;
@ -357,7 +357,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) { if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
ExtendedBolus exStop = new ExtendedBolus(new Date().getTime()); ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
exStop.source = Source.USER; exStop.source = Source.USER;
treatmentsInterface.addToHistoryExtendedBolus(exStop); treatmentsInterface.addToHistoryExtendedBolus(exStop);
} }
@ -390,13 +390,13 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName()); extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
} catch (Exception e) { } catch (Exception e) {
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));

View file

@ -243,7 +243,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
if (actualBG != null) { if (actualBG != null) {
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", "; reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
} else if (lastBG != null) { } else if (lastBG != null) {
Long agoMsec = new Date().getTime() - lastBG.date; Long agoMsec = System.currentTimeMillis() - lastBG.date;
int agoMin = (int) (agoMsec / 60d / 1000d); int agoMin = (int) (agoMsec / 60d / 1000d);
reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", "; reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", ";
} }
@ -416,7 +416,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
} }
break; break;
case "BOLUS": case "BOLUS":
if (new Date().getTime() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) { if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) {
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed); reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else if (MainApp.getConfigBuilder().isSuspended()) { } else if (MainApp.getConfigBuilder().isSuspended()) {
@ -458,7 +458,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
break; break;
default: // expect passCode here default: // expect passCode here
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed && if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) { bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
bolusWaitingForConfirmation.processed = true; bolusWaitingForConfirmation.processed = true;
PumpInterface pumpInterface = MainApp.getConfigBuilder(); PumpInterface pumpInterface = MainApp.getConfigBuilder();
if (pumpInterface != null) { if (pumpInterface != null) {
@ -481,7 +481,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
} }
} }
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed && } else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - tempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) { tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
tempBasalWaitingForConfirmation.processed = true; tempBasalWaitingForConfirmation.processed = true;
PumpInterface pumpInterface = MainApp.getConfigBuilder(); PumpInterface pumpInterface = MainApp.getConfigBuilder();
if (pumpInterface != null) { if (pumpInterface != null) {
@ -500,7 +500,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
} }
} }
} else if (cancelTempBasalWaitingForConfirmation != null && !cancelTempBasalWaitingForConfirmation.processed && } else if (cancelTempBasalWaitingForConfirmation != null && !cancelTempBasalWaitingForConfirmation.processed &&
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - cancelTempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) { cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
cancelTempBasalWaitingForConfirmation.processed = true; cancelTempBasalWaitingForConfirmation.processed = true;
PumpInterface pumpInterface = MainApp.getConfigBuilder(); PumpInterface pumpInterface = MainApp.getConfigBuilder();
if (pumpInterface != null) { if (pumpInterface != null) {
@ -519,7 +519,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
} }
} }
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed && } else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) { calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
calibrationWaitingForConfirmation.processed = true; calibrationWaitingForConfirmation.processed = true;
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested); boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
if (result) { if (result) {
@ -530,10 +530,10 @@ public class SmsCommunicatorPlugin implements PluginBase {
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed && } else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && new Date().getTime() - suspendWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) { suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
suspendWaitingForConfirmation.processed = true; suspendWaitingForConfirmation.processed = true;
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop(); final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
activeloop.suspendTo(new Date().getTime() + suspendWaitingForConfirmation.duration * 60L * 1000); activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(); PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60); NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshGui(false));

View file

@ -129,7 +129,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public static void initializeTreatmentData() { public static void initializeTreatmentData() {
// Treatments // Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false); treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
} }
@ -137,7 +137,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public static void initializeTempBasalData() { public static void initializeTempBasalData() {
// Treatments // Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false)); tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false));
@ -146,14 +146,14 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public static void initializeExtendedBolusData() { public static void initializeExtendedBolusData() {
// Treatments // Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false)); extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false));
} }
public void initializeTempTargetData() { public void initializeTempTargetData() {
long fromMills = new Date().getTime() - 60 * 60 * 1000L * 24; long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24;
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false)); tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false));
} }
@ -198,7 +198,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public void updateTotalIOBTreatments() { public void updateTotalIOBTreatments() {
IobTotal total = getCalculationToTimeTreatments(new Date().getTime()); IobTotal total = getCalculationToTimeTreatments(System.currentTimeMillis());
lastTreatmentCalculation = total; lastTreatmentCalculation = total;
} }
@ -210,7 +210,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Profile profile = MainApp.getConfigBuilder().getProfile(); Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) return result; if (profile == null) return result;
long now = new Date().getTime(); long now = System.currentTimeMillis();
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue(); long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
for (Treatment treatment : treatments) { for (Treatment treatment : treatments) {
@ -250,7 +250,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public boolean isInHistoryRealTempBasalInProgress() { public boolean isInHistoryRealTempBasalInProgress() {
return getRealTempBasalFromHistory(new Date().getTime()) != null; return getRealTempBasalFromHistory(System.currentTimeMillis()) != null;
} }
@Override @Override
@ -260,12 +260,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return getTempBasalFromHistory(new Date().getTime()) != null; return getTempBasalFromHistory(System.currentTimeMillis()) != null;
} }
@Override @Override
public boolean isInHistoryExtendedBoluslInProgress() { public boolean isInHistoryExtendedBoluslInProgress() {
return getExtendedBolusFromHistory(new Date().getTime()) != null; //TODO: crosscheck here return getExtendedBolusFromHistory(System.currentTimeMillis()) != null; //TODO: crosscheck here
} }
@Subscribe @Subscribe
@ -318,7 +318,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public void updateTotalIOBTempBasals() { public void updateTotalIOBTempBasals() {
IobTotal total = getCalculationToTimeTempBasals(new Date().getTime()); IobTotal total = getCalculationToTimeTempBasals(System.currentTimeMillis());
lastTempBasalsCalculation = total; lastTempBasalsCalculation = total;
} }
@ -355,7 +355,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public double getTempBasalAbsoluteRateHistory() { public double getTempBasalAbsoluteRateHistory() {
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();
TemporaryBasal tb = getTempBasalFromHistory(new Date().getTime()); TemporaryBasal tb = getTempBasalFromHistory(System.currentTimeMillis());
if (tb != null) { if (tb != null) {
if (tb.isAbsolute) { if (tb.isAbsolute) {
return tb.absoluteRate; return tb.absoluteRate;
@ -371,7 +371,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public double getTempBasalRemainingMinutesFromHistory() { public double getTempBasalRemainingMinutesFromHistory() {
if (isTempBasalInProgress()) if (isTempBasalInProgress())
return getTempBasalFromHistory(new Date().getTime()).getPlannedRemainingMinutes(); return getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes();
return 0; return 0;
} }
@ -414,7 +414,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public long oldestDataAvailable() { public long oldestDataAvailable() {
long oldestTime = new Date().getTime(); long oldestTime = System.currentTimeMillis();
if (tempBasals.size() > 0) if (tempBasals.size() > 0)
oldestTime = Math.min(oldestTime, tempBasals.get(0).date); oldestTime = Math.min(oldestTime, tempBasals.get(0).date);
if (extendedBoluses.size() > 0) if (extendedBoluses.size() > 0)

View file

@ -78,7 +78,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
holder.date.setText(DateUtil.dateAndTimeString(t.date)); holder.date.setText(DateUtil.dateAndTimeString(t.date));
holder.insulin.setText(DecimalFormatter.to2Decimal(t.insulin) + " U"); holder.insulin.setText(DecimalFormatter.to2Decimal(t.insulin) + " U");
holder.carbs.setText(DecimalFormatter.to0Decimal(t.carbs) + " g"); holder.carbs.setText(DecimalFormatter.to0Decimal(t.carbs) + " g");
Iob iob = t.iobCalc(new Date().getTime(), profile.getDia()); Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U"); holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U"); holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous)); holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));

View file

@ -82,7 +82,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
holder.duration.setText(DecimalFormatter.to0Decimal(extendedBolus.durationInMinutes) + " min"); holder.duration.setText(DecimalFormatter.to0Decimal(extendedBolus.durationInMinutes) + " min");
holder.insulin.setText(DecimalFormatter.to2Decimal(extendedBolus.insulin) + " U"); holder.insulin.setText(DecimalFormatter.to2Decimal(extendedBolus.insulin) + " U");
holder.realDuration.setText(DecimalFormatter.to0Decimal(extendedBolus.getRealDuration()) + " min"); holder.realDuration.setText(DecimalFormatter.to0Decimal(extendedBolus.getRealDuration()) + " min");
IobTotal iob = extendedBolus.iobCalc(new Date().getTime()); IobTotal iob = extendedBolus.iobCalc(System.currentTimeMillis());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iob) + " U"); holder.iob.setText(DecimalFormatter.to2Decimal(iob.iob) + " U");
holder.insulinSoFar.setText(DecimalFormatter.to2Decimal(extendedBolus.insulinSoFar()) + " U"); holder.insulinSoFar.setText(DecimalFormatter.to2Decimal(extendedBolus.insulinSoFar()) + " U");
holder.ratio.setText(DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + " U/h"); holder.ratio.setText(DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + " U/h");
@ -90,7 +90,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
else else
holder.date.setTextColor(holder.insulin.getCurrentTextColor()); holder.date.setTextColor(holder.insulin.getCurrentTextColor());
if (extendedBolus.iobCalc(new Date().getTime()).iob != 0) if (extendedBolus.iobCalc(System.currentTimeMillis()).iob != 0)
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
else else
holder.iob.setTextColor(holder.insulin.getCurrentTextColor()); holder.iob.setTextColor(holder.insulin.getCurrentTextColor());

View file

@ -93,7 +93,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
holder.percent.setText(DecimalFormatter.to0Decimal(tempBasal.percentRate) + "%"); holder.percent.setText(DecimalFormatter.to0Decimal(tempBasal.percentRate) + "%");
} }
holder.realDuration.setText(DecimalFormatter.to0Decimal(tempBasal.getRealDuration()) + " min"); holder.realDuration.setText(DecimalFormatter.to0Decimal(tempBasal.getRealDuration()) + " min");
IobTotal iob = tempBasal.iobCalc(new Date().getTime()); IobTotal iob = tempBasal.iobCalc(System.currentTimeMillis());
holder.iob.setText(DecimalFormatter.to2Decimal(iob.basaliob) + " U"); holder.iob.setText(DecimalFormatter.to2Decimal(iob.basaliob) + " U");
holder.netInsulin.setText(DecimalFormatter.to2Decimal(iob.netInsulin) + " U"); holder.netInsulin.setText(DecimalFormatter.to2Decimal(iob.netInsulin) + " U");
holder.netRatio.setText(DecimalFormatter.to2Decimal(iob.netRatio) + " U/h"); holder.netRatio.setText(DecimalFormatter.to2Decimal(iob.netRatio) + " U/h");
@ -103,7 +103,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
else else
holder.date.setTextColor(holder.netRatio.getCurrentTextColor()); holder.date.setTextColor(holder.netRatio.getCurrentTextColor());
if (tempBasal.iobCalc(new Date().getTime()).basaliob != 0) if (tempBasal.iobCalc(System.currentTimeMillis()).basaliob != 0)
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive)); holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
else else
holder.iob.setTextColor(holder.netRatio.getCurrentTextColor()); holder.iob.setTextColor(holder.netRatio.getCurrentTextColor());

View file

@ -276,7 +276,7 @@ public class ActionStringHandler {
} }
//Check for Temp-Target: //Check for Temp-Target:
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
if (tempTarget != null) { if (tempTarget != null) {
ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()); ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits());
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()); ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
@ -347,7 +347,7 @@ public class ActionStringHandler {
private static void generateTempTarget(int duration, double low, double high) { private static void generateTempTarget(int duration, double low, double high) {
TempTarget tempTarget = new TempTarget(); TempTarget tempTarget = new TempTarget();
tempTarget.date = new Date().getTime(); tempTarget.date = System.currentTimeMillis();
tempTarget.durationInMinutes = duration; tempTarget.durationInMinutes = duration;
tempTarget.reason = "WearPlugin"; tempTarget.reason = "WearPlugin";
tempTarget.source = Source.USER; tempTarget.source = Source.USER;

View file

@ -540,7 +540,7 @@ public class WatchUpdaterService extends WearableListenerService implements
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) { if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(new Date().getTime()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (shortString) { if (shortString) {
status += activeTemp.toStringShort(); status += activeTemp.toStringShort();
} else { } else {

View file

@ -166,7 +166,7 @@ public class StatuslinePlugin implements PluginBase {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) { if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(new Date().getTime()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (shortString) { if (shortString) {
status += activeTemp.toStringShort(); status += activeTemp.toStringShort();
} else { } else {

View file

@ -40,7 +40,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
boolean isStatusOutdated = false; boolean isStatusOutdated = false;
Date lastConnection = pump.lastDataTime(); Date lastConnection = pump.lastDataTime();
if (lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime()) if (lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis())
isStatusOutdated = true; isStatusOutdated = true;
if (Math.abs(profile.getBasal() - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep) if (Math.abs(profile.getBasal() - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep)
isBasalOutdated = true; isBasalOutdated = true;

View file

@ -97,7 +97,7 @@ public class BolusWizard {
// Insulin from superbolus for 2h. Get basal rate now and after 1h // Insulin from superbolus for 2h. Get basal rate now and after 1h
if (superBolus) { if (superBolus) {
insulinFromSuperBolus = specificProfile.getBasal(); insulinFromSuperBolus = specificProfile.getBasal();
long timeAfter1h = new Date().getTime(); long timeAfter1h = System.currentTimeMillis();
timeAfter1h += 60L * 60 * 1000; timeAfter1h += 60L * 60 * 1000;
insulinFromSuperBolus += specificProfile.getBasal(timeAfter1h); insulinFromSuperBolus += specificProfile.getBasal(timeAfter1h);
} }

View file

@ -190,7 +190,7 @@ public class NSUpload {
DeviceStatus deviceStatus = new DeviceStatus(); DeviceStatus deviceStatus = new DeviceStatus();
try { try {
LoopPlugin.LastRun lastRun = LoopPlugin.lastRun; LoopPlugin.LastRun lastRun = LoopPlugin.lastRun;
if (lastRun != null && lastRun.lastAPSRun.getTime() > new Date().getTime() - 300 * 1000L) { if (lastRun != null && lastRun.lastAPSRun.getTime() > System.currentTimeMillis() - 300 * 1000L) {
// do not send if result is older than 1 min // do not send if result is older than 1 min
APSResult apsResult = lastRun.request; APSResult apsResult = lastRun.request;
apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun)); apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun));

View file

@ -12,7 +12,7 @@ public class Profiler {
public Profiler(){} public Profiler(){}
static public void log(Logger log, String function, Date start) { static public void log(Logger log, String function, Date start) {
long msec = new Date().getTime() - start.getTime(); long msec = System.currentTimeMillis() - start.getTime();
log.debug(">>> " + function + " <<< executed in " + msec + " miliseconds"); log.debug(">>> " + function + " <<< executed in " + msec + " miliseconds");
} }
} }

View file

@ -48,7 +48,7 @@ public class XdripCalibrations {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putDouble("glucose_number", bg); bundle.putDouble("glucose_number", bg);
bundle.putString("units", MainApp.getConfigBuilder().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol"); bundle.putString("units", MainApp.getConfigBuilder().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
bundle.putLong("timestamp", new Date().getTime()); bundle.putLong("timestamp", System.currentTimeMillis());
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION); Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
intent.putExtras(bundle); intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

View file

@ -626,7 +626,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
} }
for (int i = 0; i < bgDataList.size(); i++) { for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) { if (bgDataList.get(i).timestamp < (System.currentTimeMillis() - (1000 * 60 * 60 * 5))) {
bgDataList.remove(i); //Get rid of anything more than 5 hours old bgDataList.remove(i); //Get rid of anything more than 5 hours old
break; break;
} }

View file

@ -393,7 +393,7 @@ protected abstract void setColorDark();
} }
for (int i = 0; i < bgDataList.size(); i++) { for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) { if (bgDataList.get(i).timestamp < (System.currentTimeMillis() - (1000 * 60 * 60 * 5))) {
bgDataList.remove(i); //Get rid of anything more than 5 hours old bgDataList.remove(i); //Get rid of anything more than 5 hours old
break; break;
} }

View file

@ -56,8 +56,8 @@ public class BgGraphBuilder {
//used for low resolution screen. //used for low resolution screen.
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.context = context; this.context = context;
this.highMark = aBgList.get(aBgList.size() - 1).high; this.highMark = aBgList.get(aBgList.size() - 1).high;
@ -76,8 +76,8 @@ public class BgGraphBuilder {
} }
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.context = context; this.context = context;
this.highMark = aBgList.get(aBgList.size() - 1).high; this.highMark = aBgList.get(aBgList.size() - 1).high;
@ -317,7 +317,7 @@ public class BgGraphBuilder {
SimpleDateFormat timeFormat = new SimpleDateFormat(is24? "HH" : "h a"); SimpleDateFormat timeFormat = new SimpleDateFormat(is24? "HH" : "h a");
timeFormat.setTimeZone(TimeZone.getDefault()); timeFormat.setTimeZone(TimeZone.getDefault());
double start_hour = today.getTime().getTime(); double start_hour = today.getTime().getTime();
double timeNow = new Date().getTime(); double timeNow = System.currentTimeMillis();
for (int l = 0; l <= 24; l++) { for (int l = 0; l <= 24; l++) {
if ((start_hour + (60000 * 60 * (l))) < timeNow) { if ((start_hour + (60000 * 60 * (l))) < timeNow) {
if ((start_hour + (60000 * 60 * (l + 1))) >= timeNow) { if ((start_hour + (60000 * 60 * (l + 1))) >= timeNow) {

View file

@ -596,7 +596,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
Log.d("addToWatchSet", "start removing bgDataList.size(): " + bgDataList.size()); Log.d("addToWatchSet", "start removing bgDataList.size(): " + bgDataList.size());
HashSet removeSet = new HashSet(); HashSet removeSet = new HashSet();
double threshold = (new Date().getTime() - (1000 * 60 * 5 * holdInMemory())); double threshold = (System.currentTimeMillis() - (1000 * 60 * 5 * holdInMemory()));
for (BgWatchData data : bgDataList) { for (BgWatchData data : bgDataList) {
if (data.timestamp < threshold) { if (data.timestamp < threshold) {
removeSet.add(data); removeSet.add(data);
@ -674,7 +674,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
} }
float offsetMultiplier = (((displaySize.x / 2f) - PADDING) / 12f); float offsetMultiplier = (((displaySize.x / 2f) - PADDING) / 12f);
float offset = (float) Math.max(1, Math.ceil((new Date().getTime() - entry.timestamp) / (1000 * 60 * 5))); float offset = (float) Math.max(1, Math.ceil((System.currentTimeMillis() - entry.timestamp) / (1000 * 60 * 5)));
size = bgToAngle((float) entry.sgv); size = bgToAngle((float) entry.sgv);
addArch(canvas, offset * offsetMultiplier + 10, color, (float) size); addArch(canvas, offset * offsetMultiplier + 10, color, (float) size);
addArch(canvas, (float) size, offset * offsetMultiplier + 10, getBackgroundColor(), (float) (360 - size)); addArch(canvas, (float) size, offset * offsetMultiplier + 10, getBackgroundColor(), (float) (360 - size));
@ -700,7 +700,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
barColor = darken(getLowColor(), .5); barColor = darken(getLowColor(), .5);
} }
float offsetMultiplier = (((displaySize.x / 2f) - PADDING) / 12f); float offsetMultiplier = (((displaySize.x / 2f) - PADDING) / 12f);
float offset = (float) Math.max(1, Math.ceil((new Date().getTime() - entry.timestamp) / (1000 * 60 * 5))); float offset = (float) Math.max(1, Math.ceil((System.currentTimeMillis() - entry.timestamp) / (1000 * 60 * 5)));
size = bgToAngle((float) entry.sgv); size = bgToAngle((float) entry.sgv);
addArch(canvas, offset * offsetMultiplier + 11, barColor, (float) size - 2); // Dark Color Bar addArch(canvas, offset * offsetMultiplier + 11, barColor, (float) size - 2); // Dark Color Bar
addArch(canvas, (float) size - 2, offset * offsetMultiplier + 11, indicatorColor, 2f); // Indicator at end of bar addArch(canvas, (float) size - 2, offset * offsetMultiplier + 11, indicatorColor, 2f); // Indicator at end of bar