loop context menu fix

This commit is contained in:
Milos Kozak 2017-04-08 20:13:30 +02:00
parent b9f9c88f7a
commit d41d5f9e6b

View file

@ -342,48 +342,48 @@ public class OverviewFragment extends Fragment {
@Override
public boolean onContextItemSelected(MenuItem item) {
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if (item.getTitle() == MainApp.sResources.getString(R.string.disableloop)) {
if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
activeloop.setFragmentEnabled(PluginBase.LOOP, false);
activeloop.setFragmentVisible(PluginBase.LOOP, false);
MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.enableloop)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
activeloop.setFragmentVisible(PluginBase.LOOP, true);
MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.resume)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
activeloop.suspendTo(0L);
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
MainApp.bus().post(new EventRefreshGui(false));
}
});
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.suspendloopfor1h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
activeloop.suspendTo(new Date().getTime() + 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.suspendloopfor2h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.suspendloopfor3h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.suspendloopfor10h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
activeloop.suspendTo(new Date().getTime() + 10 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false));
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.disconnectpumpfor30m)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
activeloop.suspendTo(new Date().getTime() + 30L * 60 * 1000);
sHandler.post(new Runnable() {
@Override
@ -396,42 +396,42 @@ public class OverviewFragment extends Fragment {
}
});
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.disconnectpumpfor1h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
activeloop.suspendTo(new Date().getTime() + 1 * 60L * 60 * 1000);
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
MainApp.bus().post(new EventRefreshGui(false));
}
});
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.disconnectpumpfor2h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
MainApp.bus().post(new EventRefreshGui(false));
}
});
return true;
} else if (item.getTitle() == MainApp.sResources.getString(R.string.disconnectpumpfor3h)) {
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshGui(false));
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
MainApp.bus().post(new EventRefreshGui(false));
}
});
return true;