From 97bbc00dcfa95d59a327f4b7f447735ed0668e42 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 8 Jun 2018 06:19:02 +0200 Subject: [PATCH] Don't set text onunbound gui elements --- .../plugins/PumpDanaR/DanaRFragment.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index b11cd87278..068ad3ae1f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -153,19 +153,24 @@ public class DanaRFragment extends SubscriberFragment { activity.runOnUiThread( new Runnable() { @Override - public void run() { - if (c.sStatus == EventPumpStatusChanged.CONNECTING) - btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"); - else if (c.sStatus == EventPumpStatusChanged.CONNECTED) - btConnectionView.setText("{fa-bluetooth}"); - else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED) - btConnectionView.setText("{fa-bluetooth-b}"); + public void run() { + synchronized(DanaRFragment.this){ - if (!status.equals("")) { - pumpStatusView.setText(status); - pumpStatusLayout.setVisibility(View.VISIBLE); - } else { - pumpStatusLayout.setVisibility(View.GONE); + if(btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null ) return; + + if (c.sStatus == EventPumpStatusChanged.CONNECTING) + btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"); + else if (c.sStatus == EventPumpStatusChanged.CONNECTED) + btConnectionView.setText("{fa-bluetooth}"); + else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED) + btConnectionView.setText("{fa-bluetooth-b}"); + + if (!status.equals("")) { + pumpStatusView.setText(status); + pumpStatusLayout.setVisibility(View.VISIBLE); + } else { + pumpStatusLayout.setVisibility(View.GONE); + } } } }