fix profileswitch reloads
This commit is contained in:
parent
0f40670c24
commit
6fca923275
6 changed files with 22 additions and 13 deletions
|
@ -37,6 +37,7 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
|
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
|
@ -1507,7 +1508,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
old.copyFrom(profileSwitch);
|
old.copyFrom(profileSwitch);
|
||||||
getDaoProfileSwitch().create(old);
|
getDaoProfileSwitch().create(old);
|
||||||
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1526,20 +1527,20 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
old.copyFrom(profileSwitch);
|
old.copyFrom(profileSwitch);
|
||||||
getDaoProfileSwitch().create(old);
|
getDaoProfileSwitch().create(old);
|
||||||
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (profileSwitch.source == Source.USER) {
|
if (profileSwitch.source == Source.USER) {
|
||||||
getDaoProfileSwitch().create(profileSwitch);
|
getDaoProfileSwitch().create(profileSwitch);
|
||||||
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
|
||||||
scheduleTemporaryTargetChange();
|
scheduleProfileSwitchChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -1561,6 +1562,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
log.debug("Firing EventProfileSwitchChange");
|
log.debug("Firing EventProfileSwitchChange");
|
||||||
|
MainApp.bus().post(new EventReloadProfileSwitchData());
|
||||||
MainApp.bus().post(new EventProfileSwitchChange());
|
MainApp.bus().post(new EventProfileSwitchChange());
|
||||||
scheduledProfileSwitchEventPost = null;
|
scheduledProfileSwitchEventPost = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
return Color.CYAN;
|
return Color.CYAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String log() {
|
public String toString() {
|
||||||
return "ProfileSwitch{" +
|
return "ProfileSwitch{" +
|
||||||
"date=" + date +
|
"date=" + date +
|
||||||
"date=" + DateUtil.dateAndTimeString(date) +
|
"date=" + DateUtil.dateAndTimeString(date) +
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 12.06.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventReloadProfileSwitchData {
|
||||||
|
}
|
|
@ -619,13 +619,13 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
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 = new Date().getTime();
|
||||||
profileSwitch.source = Source.PUMP;
|
profileSwitch.source = Source.USER;
|
||||||
profileSwitch.profileName = profileName;
|
profileSwitch.profileName = profileName;
|
||||||
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).toString();
|
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
||||||
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName();
|
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||||
profileSwitch.durationInMinutes = data.getInt("duration");
|
profileSwitch.durationInMinutes = data.getInt("duration");
|
||||||
if (ConfigBuilderPlugin.getActiveProfileInterface() instanceof CircadianPercentageProfilePlugin) {
|
if (ConfigBuilderPlugin.getActiveProfileInterface() instanceof CircadianPercentageProfilePlugin) {
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getConfigBuilder().getActiveProfileInterface();
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) ConfigBuilderPlugin.getActiveProfileInterface();
|
||||||
profileSwitch.isCPP = true;
|
profileSwitch.isCPP = true;
|
||||||
profileSwitch.timeshift = cpp.timeshift;
|
profileSwitch.timeshift = cpp.timeshift;
|
||||||
profileSwitch.percentage = cpp.percentage;
|
profileSwitch.percentage = cpp.percentage;
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
|
ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
|
||||||
String extendedBolusText = "";
|
String extendedBolusText = "";
|
||||||
if (extendedBolus != null) {
|
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
|
||||||
extendedBolusText = extendedBolus.toString();
|
extendedBolusText = extendedBolus.toString();
|
||||||
}
|
}
|
||||||
if (extendedBolusView != null) // must not exists in all layouts
|
if (extendedBolusView != null) // must not exists in all layouts
|
||||||
|
|
|
@ -24,11 +24,10 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
import info.nightscout.androidaps.data.ProfileIntervals;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.Source;
|
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
|
@ -445,7 +444,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
// Profile Switch
|
// Profile Switch
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventProfileSwitchChange ev) {
|
public void onStatusEvent(final EventReloadProfileSwitchData ev) {
|
||||||
initializeProfileSwitchData();
|
initializeProfileSwitchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue