com.eveningoutpost.dexdrip.WidgetUpdateService Java Examples
The following examples show how to use
com.eveningoutpost.dexdrip.WidgetUpdateService.
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: ColorPicker.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); ColorCache.invalidateCache(); // TODO maybe a better way to send this message to the chart if (mParent != null) { Log.d(TAG, "Calling refresh on parent"); try { mParent.refreshDrawableState(); } catch (Exception e) { Log.e(TAG, "Got exception refreshing drawablestate: " + e); } } else { Log.d(TAG, "mparent is null :("); } notifyChanged(); // TODO probably should check whether data has actually changed before updating all the graphics Home.staticRefreshBGCharts(true); WidgetUpdateService.staticRefreshWidgets(); Notifications.staticUpdateNotification(); }
Example #2
Source File: ColorPicker.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); ColorCache.invalidateCache(); // TODO maybe a better way to send this message to the chart if (mParent != null) { Log.d(TAG, "Calling refresh on parent"); try { mParent.refreshDrawableState(); } catch (Exception e) { Log.e(TAG, "Got exception refreshing drawablestate: " + e); } } else { Log.d(TAG, "mparent is null :("); } notifyChanged(); // TODO probably should check whether data has actually changed before updating all the graphics Home.staticRefreshBGCharts(true); WidgetUpdateService.staticRefreshWidgets(); Notifications.staticUpdateNotification(); }
Example #3
Source File: Preferences.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Context context = preference.getContext(); if (AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0) { context.startService(new Intent(context, WidgetUpdateService.class)); } return true; }
Example #4
Source File: Preferences.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Context context = preference.getContext(); if (AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0) { context.startService(new Intent(context, WidgetUpdateService.class)); } return true; }
Example #5
Source File: Preferences.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Context context = preference.getContext(); if(AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0){ context.startService(new Intent(context, WidgetUpdateService.class)); } return true; }
Example #6
Source File: BgSendQueue.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void handleNewBgReading(final BgReading bgReading, String operation_type, Context context, boolean is_follower, boolean quick) { if (bgReading == null) { UserError.Log.wtf("BgSendQueue", "handleNewBgReading called with null bgReading!"); return; } final PowerManager.WakeLock wakeLock = JoH.getWakeLock("sendQueue", 120000); try { // Add to upload queue //if (!is_follower) { UploaderQueue.newEntry(operation_type, bgReading); //} // all this other UI stuff probably shouldn't be here but in lieu of a better method we keep with it.. if (!quick) { if (Home.activityVisible) { context.sendBroadcast(new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA)); } if (AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0) { //context.startService(new Intent(context, WidgetUpdateService.class)); JoH.startService(WidgetUpdateService.class); } } // emit local broadcast BroadcastGlucose.sendLocalBroadcast(bgReading); // TODO I don't really think this is needed anymore if (!quick && Pref.getBooleanDefaultFalse("excessive_wakelocks")) { // just keep it alive for 3 more seconds to allow the watch to be updated // dangling wakelock JoH.getWakeLock("broadcstNightWatch", 3000); } if (!quick) { NewDataObserver.newBgReading(bgReading, is_follower); } if ((!is_follower) && (Pref.getBoolean("plus_follow_master", false))) { if (Pref.getBoolean("display_glucose_from_plugin", false)) { // TODO does this currently ignore noise or is noise properly calculated on the follower? // munge bgReading for follower TODO will probably want extra option for this in future // TODO we maybe don't need deep clone for this! Check how value will be used below //GcmActivity.syncBGReading(PluggableCalibration.mungeBgReading(new Cloner().deepClone(bgReading))); GcmActivity.syncBGReading(PluggableCalibration.mungeBgReading(BgReading.fromJSON(bgReading.toJSON(true)))); } else { // send as is GcmActivity.syncBGReading(bgReading); } } // process the uploader queue if (JoH.ratelimit("start-sync-service", 30)) { JoH.startService(SyncService.class); } } finally { JoH.releaseWakeLock(wakeLock); } }
Example #7
Source File: BgSendQueue.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static void handleNewBgReading(final BgReading bgReading, String operation_type, Context context, boolean is_follower, boolean quick) { if (bgReading == null) { UserError.Log.wtf("BgSendQueue", "handleNewBgReading called with null bgReading!"); return; } final PowerManager.WakeLock wakeLock = JoH.getWakeLock("sendQueue", 120000); try { // Add to upload queue //if (!is_follower) { UploaderQueue.newEntry(operation_type, bgReading); //} // all this other UI stuff probably shouldn't be here but in lieu of a better method we keep with it.. if (!quick) { if (Home.activityVisible) { context.sendBroadcast(new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA)); } if (AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0) { //context.startService(new Intent(context, WidgetUpdateService.class)); JoH.startService(WidgetUpdateService.class); } } // emit local broadcast BroadcastGlucose.sendLocalBroadcast(bgReading); // TODO I don't really think this is needed anymore if (!quick && Pref.getBooleanDefaultFalse("excessive_wakelocks")) { // just keep it alive for 3 more seconds to allow the watch to be updated // dangling wakelock JoH.getWakeLock("broadcstNightWatch", 3000); } if (!quick) { NewDataObserver.newBgReading(bgReading, is_follower); } if ((!is_follower) && (Pref.getBoolean("plus_follow_master", false))) { if (Pref.getBoolean("display_glucose_from_plugin", false)) { // TODO does this currently ignore noise or is noise properly calculated on the follower? // munge bgReading for follower TODO will probably want extra option for this in future // TODO we maybe don't need deep clone for this! Check how value will be used below //GcmActivity.syncBGReading(PluggableCalibration.mungeBgReading(new Cloner().deepClone(bgReading))); GcmActivity.syncBGReading(PluggableCalibration.mungeBgReading(BgReading.fromJSON(bgReading.toJSON(true)))); } else { // send as is GcmActivity.syncBGReading(bgReading); } } // process the uploader queue if (JoH.ratelimit("start-sync-service", 30)) { JoH.startService(SyncService.class); } } finally { JoH.releaseWakeLock(wakeLock); } }
Example #8
Source File: BgSendQueue.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
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(); } }