Skip to content

Commit

Permalink
working NS uploader for treatments
Browse files Browse the repository at this point in the history
  • Loading branch information
timomer committed Oct 23, 2015
1 parent 4b44203 commit 2d970f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public void saveTreatmentToDB(final View view){
public void onClick(DialogInterface dialog, int which) {

treatment.save();
NSUploader.addTreatment(treatment, MainActivity.activity);
Toast.makeText(view.getContext(), treatment.value + " " + treatment.type + " saved, NOT sent to Pump", Toast.LENGTH_SHORT).show();
loadLastTreatments();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void addTreatment(Treatments treatment, Context c){
try {
treatmentJSON.put("enterdBy", "HAPP");
treatmentJSON.put("eventType", "HAPP_Treatment");
treatmentJSON.put("created_at", treatment.datetime);
treatmentJSON.put("created_at", treatment.datetime_display);

switch (treatment.type) {
case "Insulin":
Expand All @@ -56,7 +56,9 @@ public static void addTreatment(Treatments treatment, Context c){
return;
}

jsonPost(treatmentJSON, prefs.getString("nightscout_url", ""));
String url = prefs.getString("nightscout_url", "") + "/treatments/";

jsonPost(treatmentJSON, url);

} catch (JSONException e) {
Crashlytics.logException(e);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/hypodiabetic/happ/pumpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.hypodiabetic.happ.Objects.Profile;
import com.hypodiabetic.happ.Objects.TempBasal;
import com.hypodiabetic.happ.Objects.Treatments;
import com.hypodiabetic.happ.integration.nightscout.NSUploader;

import java.util.Date;

Expand Down Expand Up @@ -183,10 +184,12 @@ public void onClick(DialogInterface dialog, int which) {
String toastMsg = "";
if (insulinTreatment.value != null) {
insulinTreatment.save();
NSUploader.addTreatment(insulinTreatment, MainActivity.activity);
toastMsg += insulinTreatment.value + "U ";
}
if (carbTreatment.value != null) {
carbTreatment.save();
NSUploader.addTreatment(carbTreatment, MainActivity.activity);
toastMsg += carbTreatment.value + "g ";
}

Expand Down

0 comments on commit 2d970f9

Please sign in to comment.