Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r716 committed - Fix var checking logic to work with variety of values for yes/no.

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r716 committed - Fix var checking logic to work with variety of values for yes/no.


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r716 committed - Fix var checking logic to work with variety of values for yes/no.
  • Date: Tue, 11 Oct 2011 20:37:54 +0000

Revision: 716
Author:

Date: Tue Oct 11 13:37:21 2011
Log: Fix var checking logic to work with variety of values for yes/no.
http://code.google.com/p/ndt/source/detail?r=716

Modified:
/branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java

=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Oct 11 13:30:53 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Oct 11 13:37:21 2011
@@ -148,28 +148,28 @@

results.append('\n');

- if (variables.get("pub_mismatch") == "yes") {
+ if (isVarSet(variables, "pub_mismatch")) {

results.append(getString(R.string.results_detailed_mismatch));
} else {

results.append(getString(R.string.results_detailed_no_mismatch));
}
results.append('\n');

- if (variables.get("pub_Bad_cable") == "yes") {
+ if (isVarSet(variables, "pub_Bad_cable")) {

results.append(getString(R.string.results_detailed_cable_fault));
} else {

results.append(getString(R.string.results_detailed_no_cable_fault));
}
results.append('\n');

- if (variables.get("pub_congestion") == "yes") {
+ if (isVarSet(variables, "pub_congestion")) {

results.append(getString(R.string.results_detailed_congestion));
} else {

results.append(getString(R.string.results_detailed_no_congestion));
}
results.append('\n');

- if (variables.get("pub_natBox") == "yes") {
+ if (isVarSet(variables, "pub_natBox")) {

results.append(getString(R.string.results_detailed_nat));
} else {

results.append(getString(R.string.results_detailed_no_nat));
@@ -210,4 +210,12 @@
.size()]));
return message.concat("\n");
}
-}
+
+ private boolean isVarSet(Map<String,Object> variables, String key) {
+ Object value = variables.get(key);
+ if (value instanceof String) {
+ return "yes".equals(value) || "1".equals(value);
+ }
+ return Integer.valueOf(1).equals(value);
+ }
+}


  • [ndt-dev] [ndt] r716 committed - Fix var checking logic to work with variety of values for yes/no., ndt, 10/11/2011

Archive powered by MHonArc 2.6.16.

Top of Page