Synchronize Butterknife / Eventbus

This commit is contained in:
Nico Schmitz 2018-06-20 22:57:31 +02:00
parent 6eef71c4c0
commit c3050740a8
5 changed files with 135 additions and 123 deletions

View file

@ -176,8 +176,10 @@ public class HistoryBrowseActivity extends AppCompatActivity {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized (HistoryBrowseActivity.this) {
updateGUI("EventAutosensCalculationFinished"); updateGUI("EventAutosensCalculationFinished");
} }
}
}); });
} }
} }

View file

@ -80,7 +80,7 @@ public class LoopFragment extends SubscriberFragment {
clearGUI(); clearGUI();
final Activity activity = getActivity(); final Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> lastRunView.setText(ev.text)); activity.runOnUiThread(() -> { synchronized (LoopFragment.this) { lastRunView.setText(ev.text); } });
} }
@ -89,6 +89,7 @@ public class LoopFragment extends SubscriberFragment {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
synchronized (LoopFragment.this) {
LoopPlugin.LastRun lastRun = LoopPlugin.lastRun; LoopPlugin.LastRun lastRun = LoopPlugin.lastRun;
if (lastRun != null) { if (lastRun != null) {
requestView.setText(lastRun.request != null ? lastRun.request.toSpanned() : ""); requestView.setText(lastRun.request != null ? lastRun.request.toSpanned() : "");
@ -110,6 +111,7 @@ public class LoopFragment extends SubscriberFragment {
} }
constraintsView.setText(constraints); constraintsView.setText(constraints);
} }
}
}); });
} }
@ -117,6 +119,7 @@ public class LoopFragment extends SubscriberFragment {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
synchronized (LoopFragment.this) {
requestView.setText(""); requestView.setText("");
constraintsProcessedView.setText(""); constraintsProcessedView.setText("");
sourceView.setText(""); sourceView.setText("");
@ -124,6 +127,7 @@ public class LoopFragment extends SubscriberFragment {
lastEnactView.setText(""); lastEnactView.setText("");
tbrSetByPumpView.setText(""); tbrSetByPumpView.setText("");
smbSetByPumpView.setText(""); smbSetByPumpView.setText("");
}
}); });
} }
} }

View file

@ -87,6 +87,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized (OpenAPSSMBFragment.this) {
OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin(); OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult; DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
if (lastAPSResult != null) { if (lastAPSResult != null) {
@ -117,6 +118,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim()); autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()).toString().trim());
} }
} }
}
}); });
} }
@ -126,6 +128,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized (OpenAPSSMBFragment.this) {
resultView.setText(text); resultView.setText(text);
glucoseStatusView.setText(""); glucoseStatusView.setText("");
currentTempView.setText(""); currentTempView.setText("");
@ -137,6 +140,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
requestView.setText(""); requestView.setText("");
lastRunView.setText(""); lastRunView.setText("");
} }
}
}); });
} }
} }

View file

@ -79,7 +79,7 @@ public class NSProfileFragment extends SubscriberFragment {
public void onStatusEvent(final EventNSProfileUpdateGUI ev) { public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> updateGUI()); activity.runOnUiThread(() -> { synchronized (NSProfileFragment.this) { updateGUI(); } });
} }
@Override @Override

View file

@ -216,6 +216,7 @@ public class DanaRFragment extends SubscriberFragment {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@Override @Override
public void run() { public void run() {
synchronized(DanaRFragment.this) {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.lastConnection != 0) { if (pump.lastConnection != 0) {
Long agoMsec = System.currentTimeMillis() - pump.lastConnection; Long agoMsec = System.currentTimeMillis() - pump.lastConnection;
@ -283,6 +284,7 @@ public class DanaRFragment extends SubscriberFragment {
danar_user_options.setVisibility(View.GONE); danar_user_options.setVisibility(View.GONE);
} }
} }
}
}); });
} }