AndroidAPS/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java

64 lines
1.8 KiB
Java
Raw Normal View History

2017-02-19 19:15:14 +01:00
package info.nightscout.androidaps.events;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
/**
* Created by mike on 19.02.2017.
*/
public class EventPumpStatusChanged extends Event {
2017-02-19 19:15:14 +01:00
public static final int CONNECTING = 0;
public static final int CONNECTED = 1;
public static final int HANDSHAKING = 2;
public static final int PERFORMING = 3;
public static final int DISCONNECTING = 4;
public static final int DISCONNECTED = 5;
2017-02-19 19:15:14 +01:00
public int sStatus = DISCONNECTED;
public int sSecondsElapsed = 0;
public String sPerfomingAction = "";
2017-09-14 00:29:34 +02:00
public static String error = "";
2017-02-19 19:15:14 +01:00
public EventPumpStatusChanged(int status) {
sStatus = status;
sSecondsElapsed = 0;
2017-09-14 00:29:34 +02:00
error = "";
2017-02-19 19:15:14 +01:00
}
public EventPumpStatusChanged(int status, int secondsElapsed) {
sStatus = status;
sSecondsElapsed = secondsElapsed;
2017-09-14 00:29:34 +02:00
error = "";
}
public EventPumpStatusChanged(int status, String error) {
sStatus = status;
sSecondsElapsed = 0;
this.error = error;
2017-02-19 19:15:14 +01:00
}
public EventPumpStatusChanged(String action) {
sStatus = PERFORMING;
sSecondsElapsed = 0;
sPerfomingAction = action;
}
public String textStatus() {
if (sStatus == CONNECTING)
2018-05-02 13:46:38 +02:00
return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed);
else if (sStatus == HANDSHAKING)
return MainApp.gs(R.string.handshaking);
2017-02-19 19:15:14 +01:00
else if (sStatus == CONNECTED)
2018-05-02 13:46:38 +02:00
return MainApp.gs(R.string.connected);
2017-02-19 19:15:14 +01:00
else if (sStatus == PERFORMING)
return sPerfomingAction;
else if (sStatus == DISCONNECTING)
2018-05-02 13:46:38 +02:00
return MainApp.gs(R.string.disconnecting);
2017-02-19 19:15:14 +01:00
else if (sStatus == DISCONNECTED)
return "";
return "";
}
}