In GBDevice.toString(), return the correct state instead of the simplified one

This commit is contained in:
cpfeiffer 2016-07-05 23:35:20 +02:00
parent 154b7d28bb
commit 20d8732d10
1 changed files with 24 additions and 8 deletions

View File

@ -214,26 +214,42 @@ public class GBDevice implements Parcelable {
} }
public String getStateString() { public String getStateString() {
/* return getStateString(true);
}
/**
* for simplicity the user wont see all internal states, just connecting -> connected * for simplicity the user wont see all internal states, just connecting -> connected
* instead of connecting->connected->initializing->initialized * instead of connecting->connected->initializing->initialized
* Set simple to true to get this behavior.
*/ */
private String getStateString(boolean simple) {
switch (mState) { switch (mState) {
case NOT_CONNECTED: case NOT_CONNECTED:
return GBApplication.getContext().getString(R.string.not_connected); return GBApplication.getContext().getString(R.string.not_connected);
case WAITING_FOR_RECONNECT: case WAITING_FOR_RECONNECT:
return GBApplication.getContext().getString(R.string.waiting_for_reconnect); return GBApplication.getContext().getString(R.string.waiting_for_reconnect);
case CONNECTING: case CONNECTING:
case CONNECTED:
case INITIALIZING:
return GBApplication.getContext().getString(R.string.connecting); return GBApplication.getContext().getString(R.string.connecting);
case CONNECTED:
if (simple) {
return GBApplication.getContext().getString(R.string.connecting);
}
return GBApplication.getContext().getString(R.string.connected);
case INITIALIZING:
if (simple) {
return GBApplication.getContext().getString(R.string.connecting);
}
return GBApplication.getContext().getString(R.string.initializing);
case AUTHENTICATION_REQUIRED: case AUTHENTICATION_REQUIRED:
return GBApplication.getContext().getString(R.string.authentication_required); return GBApplication.getContext().getString(R.string.authentication_required);
case AUTHENTICATING: case AUTHENTICATING:
return GBApplication.getContext().getString(R.string.authenticating); return GBApplication.getContext().getString(R.string.authenticating);
case INITIALIZED: case INITIALIZED:
if (simple) {
return GBApplication.getContext().getString(R.string.connected); return GBApplication.getContext().getString(R.string.connected);
} }
return GBApplication.getContext().getString(R.string.initialized);
}
return GBApplication.getContext().getString(R.string.unknown_state); return GBApplication.getContext().getString(R.string.unknown_state);
} }
@ -323,7 +339,7 @@ public class GBDevice implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return "Device " + getName() + ", " + getAddress() + ", " + getStateString(); return "Device " + getName() + ", " + getAddress() + ", " + getStateString(false);
} }
/** /**