Merge pull request #2373 from jotomo/patch-1
#2369 Set event time for second event plus 1s too
This commit is contained in:
commit
11dd1b43fd
1 changed files with 36 additions and 30 deletions
|
@ -102,8 +102,29 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
if (insulinAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0) {
|
||||||
|
requestPrimeBolus(insulinAfterConstraints, notes)
|
||||||
|
}
|
||||||
|
if (siteChange) {
|
||||||
|
generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
||||||
|
}
|
||||||
|
if (insulinChange) {
|
||||||
|
// add a second for case of both checked
|
||||||
|
generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
||||||
|
}
|
||||||
|
}, null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.primefill), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestPrimeBolus(insulin: Double, notes: String) {
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
detailedBolusInfo.insulin = insulinAfterConstraints
|
detailedBolusInfo.insulin = insulin
|
||||||
detailedBolusInfo.context = context
|
detailedBolusInfo.context = context
|
||||||
detailedBolusInfo.source = Source.USER
|
detailedBolusInfo.source = Source.USER
|
||||||
detailedBolusInfo.isValid = false // do not count it in IOB (for pump history)
|
detailedBolusInfo.isValid = false // do not count it in IOB (for pump history)
|
||||||
|
@ -121,33 +142,18 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun generateCareportalEvent(eventType: String, time: Long, notes: String) {
|
||||||
val careportalEvent = CareportalEvent()
|
val careportalEvent = CareportalEvent()
|
||||||
careportalEvent.date = eventTime
|
|
||||||
careportalEvent.source = Source.USER
|
careportalEvent.source = Source.USER
|
||||||
if (siteChange) {
|
careportalEvent.date = time
|
||||||
careportalEvent.json = generateJson(CareportalEvent.SITECHANGE, eventTime, notes).toString()
|
careportalEvent.json = generateJson(eventType, time, notes).toString()
|
||||||
careportalEvent.eventType = CareportalEvent.SITECHANGE
|
careportalEvent.eventType = eventType
|
||||||
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
|
||||||
}
|
|
||||||
if (insulinChange) {
|
|
||||||
// add a second for case of both checked
|
|
||||||
careportalEvent.json = generateJson(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes).toString()
|
|
||||||
careportalEvent.eventType = CareportalEvent.INSULINCHANGE
|
|
||||||
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
|
||||||
}
|
|
||||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||||
}, null)
|
NSUpload.uploadEvent(eventType, time, notes)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
activity?.let { activity ->
|
|
||||||
OKDialog.show(activity, MainApp.gs(R.string.primefill), MainApp.gs(R.string.no_action_selected))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject {
|
private fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject {
|
||||||
val data = JSONObject()
|
val data = JSONObject()
|
||||||
try {
|
try {
|
||||||
data.put("eventType", careportalEvent)
|
data.put("eventType", careportalEvent)
|
||||||
|
|
Loading…
Reference in a new issue