Skip to content

Commit e458421

Browse files
ashishkumar468maskaravivek
authored andcommitted
Bug fix issue commons-app#1839, changes (commons-app#1845)
* Extracted out PageTitle object's member varaible, displayText in a variable in findTemplate() in MediaDataExtractor * added null checks for the same varaible [Lets be safe side] * replaced equals with contains, ie. displayText.contains(title), so that uploads from multiple sources which have different formats still show up coordinates which was not being shown earlier
1 parent 4ea7229 commit e458421

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/src/main/java/fr/free/nrw/commons/MediaDataExtractor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.support.annotation.Nullable;
44

5+
import android.text.TextUtils;
56
import org.w3c.dom.Document;
67
import org.w3c.dom.Element;
78
import org.w3c.dom.Node;
@@ -161,7 +162,11 @@ private Node findTemplate(Element parentNode, String title_) throws IOException
161162
Node node = nodes.item(i);
162163
if (node.getNodeName().equals("template")) {
163164
String foundTitle = getTemplateTitle(node);
164-
if (title.equals(new PageTitle(foundTitle).getDisplayText())) {
165+
String displayText = new PageTitle(foundTitle).getDisplayText();
166+
//replaced equals with contains because multiple sources had multiple formats
167+
//say from two sources I had {{Location|12.958117388888889|77.6440805}} & {{Location dec|47.99081|7.845416|heading:255.9}},
168+
//So exact string match would show null results for uploads via web
169+
if (!(TextUtils.isEmpty(displayText)) && displayText.contains(title)) {
165170
return node;
166171
}
167172
}

0 commit comments

Comments
 (0)