mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 03:52:48 +00:00
Consolidate string trimming into getXmlString()
This commit is contained in:
parent
5b355a3e73
commit
e6965605c9
@ -150,7 +150,7 @@ public class NvHTTP {
|
|||||||
break;
|
break;
|
||||||
case (XmlPullParser.TEXT):
|
case (XmlPullParser.TEXT):
|
||||||
if (currentTag.peek().equals(tagname)) {
|
if (currentTag.peek().equals(tagname)) {
|
||||||
return xpp.getText();
|
return xpp.getText().trim();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -207,9 +207,9 @@ public class NvHTTP {
|
|||||||
ComputerDetails details = new ComputerDetails();
|
ComputerDetails details = new ComputerDetails();
|
||||||
String serverInfo = getServerInfo();
|
String serverInfo = getServerInfo();
|
||||||
|
|
||||||
details.name = getXmlString(serverInfo, "hostname").trim();
|
details.name = getXmlString(serverInfo, "hostname");
|
||||||
details.uuid = UUID.fromString(getXmlString(serverInfo, "uniqueid").trim());
|
details.uuid = UUID.fromString(getXmlString(serverInfo, "uniqueid"));
|
||||||
details.macAddress = getXmlString(serverInfo, "mac").trim();
|
details.macAddress = getXmlString(serverInfo, "mac");
|
||||||
|
|
||||||
// If there's no LocalIP field, use the address we hit the server on
|
// If there's no LocalIP field, use the address we hit the server on
|
||||||
String localIpStr = getXmlString(serverInfo, "LocalIP");
|
String localIpStr = getXmlString(serverInfo, "LocalIP");
|
||||||
@ -223,11 +223,11 @@ public class NvHTTP {
|
|||||||
externalIpStr = address.getHostAddress();
|
externalIpStr = address.getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
details.localIp = InetAddress.getByName(localIpStr.trim());
|
details.localIp = InetAddress.getByName(localIpStr);
|
||||||
details.remoteIp = InetAddress.getByName(externalIpStr.trim());
|
details.remoteIp = InetAddress.getByName(externalIpStr);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus").trim()) == 1 ?
|
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus")) == 1 ?
|
||||||
PairState.PAIRED : PairState.NOT_PAIRED;
|
PairState.PAIRED : PairState.NOT_PAIRED;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
details.pairState = PairState.FAILED;
|
details.pairState = PairState.FAILED;
|
||||||
@ -407,9 +407,9 @@ public class NvHTTP {
|
|||||||
// GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
|
// GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
|
||||||
// has the semantics that its name would indicate. To contain the effects of this change as much
|
// has the semantics that its name would indicate. To contain the effects of this change as much
|
||||||
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
|
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
|
||||||
String serverState = getXmlString(serverInfo, "state").trim();
|
String serverState = getXmlString(serverInfo, "state");
|
||||||
if (serverState != null && !serverState.endsWith("_SERVER_AVAILABLE")) {
|
if (serverState != null && !serverState.endsWith("_SERVER_AVAILABLE")) {
|
||||||
String game = getXmlString(serverInfo, "currentgame").trim();
|
String game = getXmlString(serverInfo, "currentgame");
|
||||||
return Integer.parseInt(game);
|
return Integer.parseInt(game);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -420,7 +420,7 @@ public class NvHTTP {
|
|||||||
public boolean isCurrentClient(String serverInfo) throws XmlPullParserException, IOException {
|
public boolean isCurrentClient(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
String currentClient = getXmlString(serverInfo, "CurrentClient");
|
String currentClient = getXmlString(serverInfo, "CurrentClient");
|
||||||
if (currentClient != null) {
|
if (currentClient != null) {
|
||||||
return !currentClient.trim().equals("0");
|
return !currentClient.equals("0");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// For versions of GFE that lack this field, we'll assume we are
|
// For versions of GFE that lack this field, we'll assume we are
|
||||||
|
Loading…
x
Reference in New Issue
Block a user