From 9d5afe30cb7f53ead1e289db5b13f5a093b55691 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 29 Sep 2022 14:05:51 +0200 Subject: [PATCH] Insight: simplify code --- .../plugins/pump/insight/LocalInsightPlugin.java | 10 +++++----- .../pump/omnipod/eros/OmnipodErosPumpPlugin.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 503b68e53f..67bc30357d 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -1173,7 +1173,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai } catch (Exception e) { aapsLogger.error("Exception while reading history", e); } - new Handler(Looper.getMainLooper()).post(() -> rxBus.send(new EventRefreshOverview("LocalInsightPlugin::readHistory", false))); + rxBus.send(new EventRefreshOverview("LocalInsightPlugin::readHistory", false)); } private void processHistoryEvents(String serial, List historyEvents) { @@ -1612,7 +1612,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai public void onStateChanged(InsightState state) { if (state == InsightState.CONNECTED) { statusLoaded = false; - new Handler(Looper.getMainLooper()).post(() -> rxBus.send(new EventDismissNotification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE))); + rxBus.send(new EventDismissNotification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE)); } else if (state == InsightState.NOT_PAIRED) { connectionService.withdrawConnectionRequest(this); statusLoaded = false; @@ -1625,9 +1625,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai activeTBR = null; activeBoluses = null; tbrOverNotificationBlock = null; - new Handler(Looper.getMainLooper()).post(() -> rxBus.send(new EventRefreshOverview("LocalInsightPlugin::onStateChanged", false))); + rxBus.send(new EventRefreshOverview("LocalInsightPlugin::onStateChanged", false)); } - new Handler(Looper.getMainLooper()).post(() -> rxBus.send(new EventLocalInsightUpdateGUI())); + rxBus.send(new EventLocalInsightUpdateGUI()); } @Override @@ -1638,7 +1638,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai @Override public void onTimeoutDuringHandshake() { Notification notification = new Notification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE, rh.gs(R.string.timeout_during_handshake), Notification.URGENT); - new Handler(Looper.getMainLooper()).post(() -> rxBus.send(new EventNewNotification(notification))); + rxBus.send(new EventNewNotification(notification)); } @Override diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index f1c8882213..eec5d61dd9 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -282,7 +282,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley super.onStart(); if (handlerThread == null) { - handlerThread = new HandlerThread(OmnipodErosPumpPlugin.class.getSimpleName()); + handlerThread = new HandlerThread(OmnipodErosPumpPlugin.class.getSimpleName() + "Handler"); handlerThread.start(); loopHandler = new Handler(handlerThread.getLooper()); }