Merge pull request #1120 from schmitzn/sync-butterknife-eventbus
Synchronize Butterknife / Eventbus (#1090)
This commit is contained in:
commit
9dc667817b
5 changed files with 197 additions and 125 deletions
|
@ -176,13 +176,19 @@ 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");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGUI(String from) {
|
void updateGUI(String from) {
|
||||||
|
|
||||||
|
if (noProfile == null || buttonDate == null || buttonZoom == null || bgGraph == null || iobGraph == null || seekBar == null)
|
||||||
|
return;
|
||||||
|
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
|
|
|
@ -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) { if (lastRunView != null) lastRunView.setText(ev.text); } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +89,8 @@ public class LoopFragment extends SubscriberFragment {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
synchronized (LoopFragment.this) {
|
||||||
|
if (!isBound()) return;
|
||||||
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 +112,7 @@ public class LoopFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
constraintsView.setText(constraints);
|
constraintsView.setText(constraints);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +120,8 @@ public class LoopFragment extends SubscriberFragment {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
synchronized (LoopFragment.this) {
|
||||||
|
if (isBound()) {
|
||||||
requestView.setText("");
|
requestView.setText("");
|
||||||
constraintsProcessedView.setText("");
|
constraintsProcessedView.setText("");
|
||||||
sourceView.setText("");
|
sourceView.setText("");
|
||||||
|
@ -124,6 +129,20 @@ public class LoopFragment extends SubscriberFragment {
|
||||||
lastEnactView.setText("");
|
lastEnactView.setText("");
|
||||||
tbrSetByPumpView.setText("");
|
tbrSetByPumpView.setText("");
|
||||||
smbSetByPumpView.setText("");
|
smbSetByPumpView.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isBound() {
|
||||||
|
return requestView != null
|
||||||
|
&& constraintsProcessedView != null
|
||||||
|
&& sourceView != null
|
||||||
|
&& lastRunView != null
|
||||||
|
&& lastEnactView != null
|
||||||
|
&& tbrSetByPumpView != null
|
||||||
|
&& smbSetByPumpView != null
|
||||||
|
&& constraintsView != null
|
||||||
|
&& runNowButton != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
synchronized (OpenAPSSMBFragment.this) {
|
||||||
|
if (!isBound()) return;
|
||||||
OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
|
OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
|
||||||
DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
|
DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
|
||||||
if (lastAPSResult != null) {
|
if (lastAPSResult != null) {
|
||||||
|
@ -117,6 +119,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 +129,8 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
synchronized (OpenAPSSMBFragment.this) {
|
||||||
|
if (isBound()) {
|
||||||
resultView.setText(text);
|
resultView.setText(text);
|
||||||
glucoseStatusView.setText("");
|
glucoseStatusView.setText("");
|
||||||
currentTempView.setText("");
|
currentTempView.setText("");
|
||||||
|
@ -137,6 +142,23 @@ public class OpenAPSSMBFragment extends SubscriberFragment {
|
||||||
requestView.setText("");
|
requestView.setText("");
|
||||||
lastRunView.setText("");
|
lastRunView.setText("");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isBound() {
|
||||||
|
return run != null
|
||||||
|
&& lastRunView != null
|
||||||
|
&& constraintsView != null
|
||||||
|
&& glucoseStatusView != null
|
||||||
|
&& currentTempView != null
|
||||||
|
&& iobDataView != null
|
||||||
|
&& profileView != null
|
||||||
|
&& mealDataView != null
|
||||||
|
&& autosensDataView != null
|
||||||
|
&& resultView != null
|
||||||
|
&& scriptdebugView != null
|
||||||
|
&& requestView != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,11 +79,14 @@ 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
|
||||||
protected void updateGUI() {
|
protected void updateGUI() {
|
||||||
|
if (noProfile == null || profileSpinner == null)
|
||||||
|
return;
|
||||||
|
|
||||||
ProfileStore profileStore = NSProfilePlugin.getPlugin().getProfile();
|
ProfileStore profileStore = NSProfilePlugin.getPlugin().getProfile();
|
||||||
if (profileStore != null) {
|
if (profileStore != null) {
|
||||||
ArrayList<CharSequence> profileList = profileStore.getProfileList();
|
ArrayList<CharSequence> profileList = profileStore.getProfileList();
|
||||||
|
|
|
@ -216,6 +216,9 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
synchronized(DanaRFragment.this) {
|
||||||
|
if (!isBound()) return;
|
||||||
|
|
||||||
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,7 +286,26 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
danar_user_options.setVisibility(View.GONE);
|
danar_user_options.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isBound() {
|
||||||
|
return lastConnectionView != null
|
||||||
|
&& lastBolusView != null
|
||||||
|
&& dailyUnitsView != null
|
||||||
|
&& basaBasalRateView != null
|
||||||
|
&& tempBasalView != null
|
||||||
|
&& extendedBolusView != null
|
||||||
|
&& reservoirView != null
|
||||||
|
&& batteryView != null
|
||||||
|
&& iobView != null
|
||||||
|
&& firmwareView != null
|
||||||
|
&& basalStepView != null
|
||||||
|
&& bolusStepView != null
|
||||||
|
&& serialNumberView != null
|
||||||
|
&& danar_user_options != null
|
||||||
|
&& queueView != null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue