Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hotfix/issue108 #18

Merged
merged 2 commits into from

2 participants

This page is out of date. Refresh to see the latest.
View
17 src/org/mixare/DataView.java
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
@@ -285,13 +286,15 @@ public void draw(PaintScreen dw) {
}
if(!dRes.error) {
- //jLayer = (DataHandler) dRes.obj;
- Log.i(MixView.TAG,"Adding Markers");
- dataHandler.addMarkers(dRes.getMarkers());
- dataHandler.onLocationChanged(curFix);
- // Notification
- Toast.makeText(mixContext, mixContext.getResources().getString(R.string.download_received) +" "+ dRes.source.getName(), Toast.LENGTH_SHORT).show();
-
+ if(dRes.getMarkers() != null){
+ //jLayer = (DataHandler) dRes.obj;
+ Log.i(MixView.TAG,"Adding Markers");
+
+ dataHandler.addMarkers(dRes.getMarkers());
+ dataHandler.onLocationChanged(curFix);
+ // Notification
+ Toast.makeText(mixContext, mixContext.getResources().getString(R.string.download_received) +" "+ dRes.source.getName(), Toast.LENGTH_SHORT).show();
+ }
}
}
if(dm.isDone()) {
View
24 src/org/mixare/data/convert/DataConvertor.java
@@ -63,7 +63,7 @@ public void removeDataProcessor(DataProcessor dataProcessor){
}
public List<Marker> load(String url, String rawResult, DataSource ds){
- DataProcessor dataProcessor = searchForMatchingDataProcessors(url, rawResult);
+ DataProcessor dataProcessor = searchForMatchingDataProcessors(url, rawResult, ds.getType());
if(dataProcessor == null){
dataProcessor = new MixareDataProcessor(); //using this as default if nothing is found.
}
@@ -81,18 +81,20 @@ public void run() {
return null;
}
- private DataProcessor searchForMatchingDataProcessors(String url, String rawResult){
+ private DataProcessor searchForMatchingDataProcessors(String url, String rawResult, DataSource.TYPE type){
for(DataProcessor dp : dataProcessors){
- //checking if url matches any dataprocessor identifiers
- for(String urlIdentifier : dp.getUrlMatch()){
- if(url.contains(urlIdentifier)){
- return dp;
+ if(dp.matchesRequiredType(type.name())){
+ //checking if url matches any dataprocessor identifiers
+ for(String urlIdentifier : dp.getUrlMatch()){
+ if(url.toLowerCase().contains(urlIdentifier.toLowerCase())){
+ return dp;
+ }
}
- }
- //checking if data matches any dataprocessor identifiers
- for(String dataIdentifier : dp.getDataMatch()){
- if(rawResult.contains(dataIdentifier)){
- return dp;
+ //checking if data matches any dataprocessor identifiers
+ for(String dataIdentifier : dp.getDataMatch()){
+ if(rawResult.contains(dataIdentifier)){
+ return dp;
+ }
}
}
}
View
2  src/org/mixare/data/convert/DataProcessor.java
@@ -36,5 +36,7 @@
String[] getDataMatch();
+ boolean matchesRequiredType(String type);
+
List<Marker> load(String rawData, int taskId, int colour) throws JSONException;
}
View
5 src/org/mixare/data/convert/MixareDataProcessor.java
@@ -51,6 +51,11 @@
String[] str = new String[0]; //only use this data source if all the others don't match
return str;
}
+
+ @Override
+ public boolean matchesRequiredType(String type) {
+ return true; //this datasources has no required type, it will always match.
+ }
@Override
public List<Marker> load(String rawData, int taskId, int colour) throws JSONException {
View
9 src/org/mixare/data/convert/OsmDataProcessor.java
@@ -29,6 +29,7 @@
import org.mixare.MixView;
import org.mixare.NavigationMarker;
import org.mixare.data.DataHandler;
+import org.mixare.data.DataSource;
import org.mixare.lib.marker.Marker;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -54,6 +55,14 @@
String[] str = { "mapquestapi", "osm" };
return str;
}
+
+ @Override
+ public boolean matchesRequiredType(String type) {
+ if(type.equals(DataSource.TYPE.OSM.name())){
+ return true;
+ }
+ return false;
+ }
@Override
public List<Marker> load(String rawData, int taskId, int colour)
View
9 src/org/mixare/data/convert/TwitterDataProcessor.java
@@ -29,6 +29,7 @@
import org.mixare.MixView;
import org.mixare.SocialMarker;
import org.mixare.data.DataHandler;
+import org.mixare.data.DataSource;
import org.mixare.lib.marker.Marker;
import android.util.Log;
@@ -52,6 +53,14 @@
String[] str = {"twitter"};
return str;
}
+
+ @Override
+ public boolean matchesRequiredType(String type) {
+ if(type.equals(DataSource.TYPE.TWITTER.name())){
+ return true;
+ }
+ return false;
+ }
@Override
public List<Marker> load(String rawData, int taskId, int colour)
View
9 src/org/mixare/data/convert/WikiDataProcessor.java
@@ -27,6 +27,7 @@
import org.mixare.MixView;
import org.mixare.POIMarker;
import org.mixare.data.DataHandler;
+import org.mixare.data.DataSource;
import org.mixare.lib.HtmlUnescape;
import org.mixare.data.convert.DataProcessor;
import org.mixare.lib.marker.Marker;
@@ -52,6 +53,14 @@
String[] str = {"wiki"};
return str;
}
+
+ @Override
+ public boolean matchesRequiredType(String type) {
+ if(type.equals(DataSource.TYPE.WIKIPEDIA.name())){
+ return true;
+ }
+ return false;
+ }
@Override
public List<Marker> load(String rawData, int taskId, int colour) throws JSONException {
View
8 src/org/mixare/plugin/RemoteDataHandler.java
@@ -72,6 +72,14 @@ public void buildDataHandler(){
}
}
+ @Override
+ public boolean matchesRequiredType(String type) {
+ //TODO: change the datasource so that it can have more types,
+ // so that plugins can also have a required type
+ return true;
+ }
+
+
public List<Marker> load(String rawData, int taskId, int colour) throws JSONException {
try {
List<InitialMarkerData> initialMarkerData = iDataHandlerService.load(dataHandlerName, rawData, taskId, colour);
Something went wrong with that request. Please try again.