public void updateHAPPBasal() { List<Basal> basals = Basal.getToUpdateHAPP(); Log.d("UPDATE HAPP:", basals.size() + " basals"); for (Basal basal : basals) { ObjectToSync basalSync = new ObjectToSync(null, basal); Message msg = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString("ACTION", "temp_basal"); bundle.putString("UPDATE", basalSync.asJSONString()); msg.setData(bundle); try { Log.d("UPDATE HAPP:", "HAPP INT ID " + basalSync.happ_integration_id); myService.send(msg); } catch (RemoteException e) { e.printStackTrace(); Log.d("UPDATE HAPP:", "Update FAILED for " + basalSync.happ_integration_id); } finally { Log.d("UPDATE HAPP:", "Update sent for " + basalSync.happ_integration_id); basal.happ_update = false; basal.save(); } } try { if (isBound) IncomingService.this.unbindService(myConnection); } catch (IllegalArgumentException e) { // catch if service was killed in a unclean way } }
public void updateHAPPBolus() { List<Treatment> treatments = Treatment.getToUpdateHAPP(); Log.d("UPDATE HAPP:", treatments.size() + " treatments"); for (Treatment bolus : treatments) { ObjectToSync bolusSync = new ObjectToSync(bolus, null); Message msg = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString("ACTION", "bolus_delivery"); bundle.putString("UPDATE", bolusSync.asJSONString()); msg.setData(bundle); try { Log.d("UPDATE HAPP:", "HAPP INT ID " + bolusSync.happ_integration_id); myService.send(msg); } catch (RemoteException e) { e.printStackTrace(); Log.d("UPDATE HAPP:", "Update FAILED for " + bolusSync.happ_integration_id); } finally { Log.d("UPDATE HAPP:", "Update sent for " + bolusSync.happ_integration_id); bolus.happ_update = false; bolus.save(); } } try { if (isBound) IncomingService.this.unbindService(myConnection); } catch (IllegalArgumentException e) { // catch if service was killed in a unclean way } }