Fix displaying connection problems in Combo tab.
This commit is contained in:
parent
deb566c1bd
commit
99db38a8e0
|
@ -135,11 +135,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
|
|
||||||
// last connection
|
// last connection
|
||||||
String minAgo = DateUtil.minAgo(plugin.getPump().lastSuccessfulCmdTime);
|
String minAgo = DateUtil.minAgo(plugin.getPump().lastSuccessfulCmdTime);
|
||||||
|
long min = (System.currentTimeMillis() - plugin.getPump().lastSuccessfulCmdTime) / 1000 / 60;
|
||||||
if (plugin.getPump().lastSuccessfulCmdTime + 60 * 1000 > System.currentTimeMillis()) {
|
if (plugin.getPump().lastSuccessfulCmdTime + 60 * 1000 > System.currentTimeMillis()) {
|
||||||
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
||||||
lastConnectionView.setTextColor(Color.WHITE);
|
lastConnectionView.setTextColor(Color.WHITE);
|
||||||
} else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
} else if (plugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||||
lastConnectionView.setText(getString(R.string.combo_no_pump_connection, minAgo));
|
lastConnectionView.setText(getString(R.string.combo_no_pump_connection, min));
|
||||||
lastConnectionView.setTextColor(Color.RED);
|
lastConnectionView.setTextColor(Color.RED);
|
||||||
} else if (plugin.getPump().lastCmdTime > plugin.getPump().lastSuccessfulCmdTime) {
|
} else if (plugin.getPump().lastCmdTime > plugin.getPump().lastSuccessfulCmdTime) {
|
||||||
String lastFailed = minAgo + "\n" + getString(R.string.combo_connect_attempt_failed);
|
String lastFailed = minAgo + "\n" + getString(R.string.combo_connect_attempt_failed);
|
||||||
|
|
|
@ -627,6 +627,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
* NO history, reservoir level fields are updated, this make be done separately if desired.
|
* NO history, reservoir level fields are updated, this make be done separately if desired.
|
||||||
*/
|
*/
|
||||||
private synchronized CommandResult runCommand(String activity, int retries, CommandExecution commandExecution) {
|
private synchronized CommandResult runCommand(String activity, int retries, CommandExecution commandExecution) {
|
||||||
|
pump.lastCmdTime = System.currentTimeMillis();
|
||||||
CommandResult commandResult;
|
CommandResult commandResult;
|
||||||
try {
|
try {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -659,11 +660,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
pump.lastCmdResult = commandResult;
|
pump.lastCmdResult = commandResult;
|
||||||
pump.lastCmdTime = System.currentTimeMillis();
|
|
||||||
if (commandResult.success) {
|
if (commandResult.success) {
|
||||||
pump.lastSuccessfulCmdTime = pump.lastCmdTime;
|
pump.lastSuccessfulCmdTime = pump.lastCmdTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
pump.activity = null;
|
pump.activity = null;
|
||||||
|
|
|
@ -768,7 +768,7 @@
|
||||||
<string name="combo_stats">Stats</string>
|
<string name="combo_stats">Stats</string>
|
||||||
<string name="combo_pump_state_label">State</string>
|
<string name="combo_pump_state_label">State</string>
|
||||||
<string name="combo_pump_activity">Activity</string>
|
<string name="combo_pump_activity">Activity</string>
|
||||||
<string name="combo_no_pump_connection">No successful connection for %s</string>
|
<string name="combo_no_pump_connection">No connection for %d min</string>
|
||||||
<string name="combo_connect_attempt_failed">Last connect attempt failed</string>
|
<string name="combo_connect_attempt_failed">Last connect attempt failed</string>
|
||||||
<string name="combo_last_connection_time">%s</string>
|
<string name="combo_last_connection_time">%s</string>
|
||||||
<string name="combo_tbr_remaining">%d%% (%d min remaining)</string>
|
<string name="combo_tbr_remaining">%d%% (%d min remaining)</string>
|
||||||
|
|
Loading…
Reference in a new issue