com.eveningoutpost.dexdrip.ShareModels.Models.ShareUploadPayload Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.ShareModels.Models.ShareUploadPayload. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BgUploader.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void upload(ShareUploadPayload bg) {
    shareRest.uploadBGRecords(bg, new Callback<ResponseBody>() {
        @Override
        public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
            // This should probably be pulled up into BgSendQueue or NightscoutUploader
            // where errors can be handled properly.
        }

        @Override
        public void onFailure(Throwable t) {
            // TODO add error handling in a refactoring pass
        }
    });
}
 
Example #2
Source File: ShareRest.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void uploadBGRecords(final ShareUploadPayload bg, Callback<ResponseBody> callback) {
    dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(new AuthenticatingCallback<ResponseBody>(callback) {
        @Override
        public void onRetry() {
            dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(this);
        }
    });
}
 
Example #3
Source File: NewDataObserver.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private static void uploadToShare(BgReading bgReading, boolean is_follower) {
    if ((!is_follower) && (Pref.getBooleanDefaultFalse("share_upload"))) {
        if (JoH.ratelimit("sending-to-share-upload", 10)) {
            UserError.Log.d("ShareRest", "About to call ShareRest!!");
            String receiverSn = Pref.getString("share_key", "SM00000000").toUpperCase();
            BgUploader bgUploader = new BgUploader(xdrip.getAppContext());
            bgUploader.upload(new ShareUploadPayload(receiverSn, bgReading));
        }
    }
}
 
Example #4
Source File: BgUploader.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void upload(ShareUploadPayload bg) {
    shareRest.uploadBGRecords(bg, new Callback<ResponseBody>() {
        @Override
        public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
            // This should probably be pulled up into BgSendQueue or NightscoutUploader
            // where errors can be handled properly.
        }

        @Override
        public void onFailure(Throwable t) {
            // TODO add error handling in a refactoring pass
        }
    });
}
 
Example #5
Source File: ShareRest.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void uploadBGRecords(final ShareUploadPayload bg, Callback<ResponseBody> callback) {
    dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(new AuthenticatingCallback<ResponseBody>(callback) {
        @Override
        public void onRetry() {
            dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(this);
        }
    });
}
 
Example #6
Source File: NewDataObserver.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private static void uploadToShare(BgReading bgReading, boolean is_follower) {
    if ((!is_follower) && (Pref.getBooleanDefaultFalse("share_upload"))) {
        if (JoH.ratelimit("sending-to-share-upload", 10)) {
            UserError.Log.d("ShareRest", "About to call ShareRest!!");
            String receiverSn = Pref.getString("share_key", "SM00000000").toUpperCase();
            BgUploader bgUploader = new BgUploader(xdrip.getAppContext());
            bgUploader.upload(new ShareUploadPayload(receiverSn, bgReading));
        }
    }
}
 
Example #7
Source File: BgUploader.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void upload(ShareUploadPayload bg) {
    shareRest.uploadBGRecords(bg, new Callback<ResponseBody>() {
        @Override
        public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
            // This should probably be pulled up into BgSendQueue or NightscoutUploader
            // where errors can be handled properly.
        }

        @Override
        public void onFailure(Throwable t) {
            UserError.Log.d(TAG, "Error uploading Share records: "+ t.getMessage());
        }
    });
}
 
Example #8
Source File: ShareRest.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void uploadBGRecords(final ShareUploadPayload bg, Callback<ResponseBody> callback) {
    try {
        dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(new AuthenticatingCallback<ResponseBody>(callback) {
            @Override
            public void onRetry() {
            dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(this);
        }
    });
    } catch (ShareException e) {
        callback.onFailure(e);
    }
}
 
Example #9
Source File: DexcomShare.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/PostReceiverEgvRecords")
Call<ResponseBody> uploadBGRecords(@Query("sessionId") String sessionId, @Body ShareUploadPayload payload);
 
Example #10
Source File: DexcomShare.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/PostReceiverEgvRecords")
Call<ResponseBody> uploadBGRecords(@Query("sessionId") String sessionId, @Body ShareUploadPayload payload);
 
Example #11
Source File: BgSendQueue.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public static void handleNewBgReading(BgReading bgReading, String operation_type, Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
            "sendQueue");
    wakeLock.acquire();
    try {
    	
   		addToQueue(bgReading, operation_type);

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

        Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA);
        context.sendBroadcast(updateIntent);

        if(AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0){
            context.startService(new Intent(context, WidgetUpdateService.class));
        }


        if (prefs.getBoolean("broadcast_data_through_intents", false)) {

            //prepare data
            double calculated_value = bgReading.calculated_value;
            boolean hide_slope = bgReading.hide_slope;
            String slopeName = hide_slope?null:bgReading.slopeName();
            int batteryLevel = getBatteryLevel(context);
            final long timestamp = bgReading.timestamp;
            Calibration cal = Calibration.last();
            double raw = NightscoutUploader.getNightscoutRaw(bgReading, cal);
            double slope = BgReading.currentSlope();

            //send broadcast
            BgEstimateBroadcaster.broadcastBgEstimate(calculated_value, raw, timestamp, slope, slopeName, batteryLevel, context);

            //just keep it alive for 3 more seconds to allow the watch to be updated
            // TODO: change NightWatch to not allow the system to sleep.
            powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                    "broadcastNightWatch").acquire(3000);

        }

        // send to wear
        if (prefs.getBoolean("wear_sync", false)) {

            /*By integrating the watch part of Nightwatch we inherited the same wakelock
                problems NW had - so adding the same quick fix for now.
                TODO: properly "wakelock" the wear (and probably pebble) services
             */
            context.startService(new Intent(context, WatchUpdaterService.class));
            powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                    "quickFix3").acquire(15000);
        }

        // send to pebble
        if(prefs.getBoolean("broadcast_to_pebble", false)) {
            context.startService(new Intent(context, PebbleSync.class));
        }



        if (prefs.getBoolean("share_upload", false)) {
            Log.d("ShareRest", "About to call ShareRest!!");
            String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase();
            BgUploader bgUploader = new BgUploader(context);
            bgUploader.upload(new ShareUploadPayload(receiverSn, bgReading));
        }
        context.startService(new Intent(context, SyncService.class));

        //Text to speech
        Log.d("BgToSpeech", "gonna call speak");
        BgToSpeech.speak(bgReading.calculated_value, bgReading.timestamp);


    } finally {
        wakeLock.release();
    }
}
 
Example #12
Source File: DexcomShare.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/PostReceiverEgvRecords")
Call<ResponseBody> uploadBGRecords(@Query("sessionId") String sessionId, @Body ShareUploadPayload payload);