Skip to content

Commit 6f0ffdb

Browse files
committed
Fixes #121
1 parent 085a3de commit 6f0ffdb

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

app/app.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
8686
<orderEntry type="sourceFolder" forTests="false" />
8787
<orderEntry type="library" exported="" name="disklrucache-2.0.2" level="project" />
88+
<orderEntry type="library" exported="" name="commons-lang3-3.0" level="project" />
8889
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
8990
<orderEntry type="library" exported="" name="okhttp-urlconnection-2.4.0" level="project" />
9091
<orderEntry type="library" exported="" name="guava-18.0" level="project" />

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ repositories {
2626
dependencies {
2727
compile fileTree(dir: 'libs', include: ['*.jar'])
2828
compile group: 'com.google.guava', name: 'guava', version: '18.0'
29+
compile 'org.apache.commons:commons-lang3:3.0'
2930
compile project(':MapboxAndroidSDK')
3031
compile 'com.android.support:appcompat-v7:22.2.1'
3132
compile 'com.android.support:design:22.2.1'

app/src/main/java/org/redcross/openmapkit/odkcollect/tag/ODKTag.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
import android.widget.EditText;
66
import android.widget.TextView;
77

8+
import org.apache.commons.lang3.StringUtils;
9+
810
import java.util.ArrayList;
911
import java.util.Collection;
1012
import java.util.HashMap;
13+
import java.util.HashSet;
1114
import java.util.LinkedHashMap;
1215
import java.util.List;
1316
import java.util.Map;
17+
import java.util.Set;
1418

1519
/**
1620
* Structure for ODK OSM Tag elements in XForm.
@@ -95,32 +99,26 @@ public boolean hasCheckedTagValues() {
9599
}
96100

97101
public String getSemiColonDelimitedTagValues(String customValues) {
98-
String values = null;
99-
boolean firstVal = true;
102+
Set<String> values = new HashSet<>();
100103
for (CheckBox cb : checkBoxes) {
101104
if (cb.isChecked()) {
102105
int id = cb.getId();
103106
ODKTagItem item = buttonIdToODKTagItemHash.get(id);
104107
if (item != null) {
105-
if (firstVal) {
106-
firstVal = false;
107-
values = item.getValue();
108-
} else {
109-
values += ';' + item.getValue();
110-
}
108+
values.add(item.getValue());
111109
}
112110
}
113111
}
114112
if (customValues != null) {
115113
customValues = customValues.trim();
116-
if (customValues.length() > 0) {
117-
if (firstVal) {
118-
values = customValues;
119-
} else {
120-
values += ';' + customValues;
114+
String[] customValuesArr = customValues.split(";");
115+
if (customValuesArr.length > 0) {
116+
for (int i = 0; i < customValuesArr.length; i++) {
117+
String customVal = customValuesArr[i];
118+
values.add(customVal);
121119
}
122120
}
123121
}
124-
return values;
122+
return StringUtils.join(values, ";");
125123
}
126124
}

0 commit comments

Comments
 (0)