Bug fix issue #1839, changes (#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
This commit is contained in:
Ashish Kumar 2018-08-22 10:13:36 +05:30 committed by Vivek Maskara
parent 4ea7229876
commit e4584217d2

View file

@ -2,6 +2,7 @@ package fr.free.nrw.commons;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -161,7 +162,11 @@ public class MediaDataExtractor {
Node node = nodes.item(i);
if (node.getNodeName().equals("template")) {
String foundTitle = getTemplateTitle(node);
if (title.equals(new PageTitle(foundTitle).getDisplayText())) {
String displayText = new PageTitle(foundTitle).getDisplayText();
//replaced equals with contains because multiple sources had multiple formats
//say from two sources I had {{Location|12.958117388888889|77.6440805}} & {{Location dec|47.99081|7.845416|heading:255.9}},
//So exact string match would show null results for uploads via web
if (!(TextUtils.isEmpty(displayText)) && displayText.contains(title)) {
return node;
}
}