use of sugar.free.sightparser.applayer.messages.remote_control.SetPumpStatusMessage in project SightRemote by TebbeUbben.
the class StatusActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item == startPump) {
if (getServiceConnector().getStatus() == Status.CONNECTED) {
SetPumpStatusMessage message = new SetPumpStatusMessage();
message.setPumpStatus(PumpStatus.STARTED);
SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
(confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.start_pump_confirmation), () -> {
startPump.setVisible(false);
if (StatusActivity.this.taskRunner != null)
StatusActivity.this.taskRunner.cancel();
taskRunner.fetch(errorToastResultCallback);
handler.removeCallbacks(taskRunnerRunnable);
handler.postDelayed(taskRunnerRunnable, 500);
})).show();
}
return true;
} else if (item == stopPump) {
if (getServiceConnector().getStatus() == Status.CONNECTED) {
SetPumpStatusMessage message = new SetPumpStatusMessage();
message.setPumpStatus(PumpStatus.STOPPED);
SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
(confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.stop_pump_confirmation), () -> {
stopPump.setVisible(false);
if (StatusActivity.this.taskRunner != null)
StatusActivity.this.taskRunner.cancel();
taskRunner.fetch(errorToastResultCallback);
handler.removeCallbacks(taskRunnerRunnable);
handler.postDelayed(taskRunnerRunnable, 500);
})).show();
}
return true;
}
return super.onOptionsItemSelected(item);
}
Aggregations