fix profileswitch reloads

This commit is contained in:
Milos Kozak 2017-06-12 13:11:16 +02:00
parent 0f40670c24
commit 6fca923275
6 changed files with 22 additions and 13 deletions

View file

@ -37,6 +37,7 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
import info.nightscout.androidaps.events.EventReloadTempBasalData;
import info.nightscout.androidaps.events.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTempBasalChange;
@ -1507,7 +1508,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
old.copyFrom(profileSwitch);
getDaoProfileSwitch().create(old);
log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleTemporaryTargetChange();
scheduleProfileSwitchChange();
return true;
}
return false;
@ -1526,20 +1527,20 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
old.copyFrom(profileSwitch);
getDaoProfileSwitch().create(old);
log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString());
scheduleTemporaryTargetChange();
scheduleProfileSwitchChange();
return true;
}
}
}
getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleTemporaryTargetChange();
scheduleProfileSwitchChange();
return true;
}
if (profileSwitch.source == Source.USER) {
getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleTemporaryTargetChange();
scheduleProfileSwitchChange();
return true;
}
} catch (SQLException e) {
@ -1561,6 +1562,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
class PostRunnable implements Runnable {
public void run() {
log.debug("Firing EventProfileSwitchChange");
MainApp.bus().post(new EventReloadProfileSwitchData());
MainApp.bus().post(new EventProfileSwitchChange());
scheduledProfileSwitchEventPost = null;
}

View file

@ -187,7 +187,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
return Color.CYAN;
}
public String log() {
public String toString() {
return "ProfileSwitch{" +
"date=" + date +
"date=" + DateUtil.dateAndTimeString(date) +

View file

@ -0,0 +1,8 @@
package info.nightscout.androidaps.events;
/**
* Created by mike on 12.06.2017.
*/
public class EventReloadProfileSwitchData {
}

View file

@ -619,13 +619,13 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
String profileName = data.getString("profile");
ProfileSwitch profileSwitch = new ProfileSwitch();
profileSwitch.date = new Date().getTime();
profileSwitch.source = Source.PUMP;
profileSwitch.source = Source.USER;
profileSwitch.profileName = profileName;
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).toString();
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName();
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
profileSwitch.durationInMinutes = data.getInt("duration");
if (ConfigBuilderPlugin.getActiveProfileInterface() instanceof CircadianPercentageProfilePlugin) {
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getConfigBuilder().getActiveProfileInterface();
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) ConfigBuilderPlugin.getActiveProfileInterface();
profileSwitch.isCPP = true;
profileSwitch.timeshift = cpp.timeshift;
profileSwitch.percentage = cpp.percentage;

View file

@ -1018,7 +1018,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
String extendedBolusText = "";
if (extendedBolus != null) {
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
extendedBolusText = extendedBolus.toString();
}
if (extendedBolusView != null) // must not exists in all layouts

View file

@ -24,11 +24,10 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileIntervals;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.TemporaryBasal;
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.EventReloadTreatmentData;
import info.nightscout.androidaps.events.EventTempTargetChange;
@ -445,7 +444,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
// Profile Switch
@Subscribe
public void onStatusEvent(final EventProfileSwitchChange ev) {
public void onStatusEvent(final EventReloadProfileSwitchData ev) {
initializeProfileSwitchData();
}