API Refactoring (moving to interfaces)
This commit is contained in:
parent
cffec1c653
commit
824dc02459
5 changed files with 54 additions and 24 deletions
|
@ -1,5 +1,7 @@
|
|||
package net.osmand;
|
||||
|
||||
import java.text.Collator;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -157,5 +159,32 @@ public class LogUtil {
|
|||
|
||||
public static XmlPullParser newXMLPullParser() throws XmlPullParserException {
|
||||
return XmlPullParserFactory.newInstance().newPullParser();
|
||||
}
|
||||
}
|
||||
|
||||
public static net.osmand.Collator primaryCollator(){
|
||||
final Collator instance = Collator.getInstance();
|
||||
instance.setStrength(Collator.PRIMARY);
|
||||
return new net.osmand.Collator() {
|
||||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return instance.compare(o1, o2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return instance.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(String source, String target) {
|
||||
return instance.equals(source, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String source, String target) {
|
||||
return instance.compare(source, target);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,14 @@ package net.osmand.plus;
|
|||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.LogUtil;
|
||||
|
@ -41,11 +40,8 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
|||
public RegionAddressRepositoryBinary(BinaryMapIndexReader file, String name) {
|
||||
this.file = file;
|
||||
this.region = name;
|
||||
this.collator = Collator.getInstance(Locale.US);
|
||||
this.collator.setStrength(Collator.PRIMARY); //ignores also case
|
||||
Collator sortcollator = Collator.getInstance();
|
||||
sortcollator.setStrength(Collator.PRIMARY); //ignores also case
|
||||
this.postCodes = new TreeMap<String, City>(sortcollator);
|
||||
this.collator = LogUtil.primaryCollator();
|
||||
this.postCodes = new TreeMap<String, City>(LogUtil.primaryCollator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,9 +136,10 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
|||
if (/*name.length() >= 2 && Algoritms.containsDigit(name) && */searchVillages) {
|
||||
// also try to identify postcodes
|
||||
String uName = name.toUpperCase();
|
||||
for (City code : file.getCities(region, BinaryMapIndexReader.buildAddressRequest(resultMatcher),
|
||||
new CollatorStringMatcher(collator, uName, StringMatcherMode.CHECK_CONTAINS), false,
|
||||
BinaryMapAddressReaderAdapter.POSTCODES_TYPE)) {
|
||||
List<City> foundCities = file.getCities(region, BinaryMapIndexReader.buildAddressRequest(resultMatcher),
|
||||
new CollatorStringMatcher(uName, StringMatcherMode.CHECK_CONTAINS), false,
|
||||
BinaryMapAddressReaderAdapter.POSTCODES_TYPE);
|
||||
for (City code : foundCities) {
|
||||
citiesToFill.add(code);
|
||||
if (resultMatcher.isCancelled()) {
|
||||
return citiesToFill;
|
||||
|
@ -165,9 +162,10 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
|||
|
||||
int initialsize = citiesToFill.size();
|
||||
if (/*name.length() >= 3 && */searchVillages) {
|
||||
for (City c : file.getCities(region, BinaryMapIndexReader.buildAddressRequest(resultMatcher),
|
||||
new CollatorStringMatcher(collator, name,StringMatcherMode.CHECK_STARTS_FROM_SPACE), useEnglishNames,
|
||||
BinaryMapAddressReaderAdapter.VILLAGES_TYPE)) {
|
||||
List<City> foundCities = file.getCities(region, BinaryMapIndexReader.buildAddressRequest(resultMatcher),
|
||||
new CollatorStringMatcher(name,StringMatcherMode.CHECK_STARTS_FROM_SPACE), useEnglishNames,
|
||||
BinaryMapAddressReaderAdapter.VILLAGES_TYPE);
|
||||
for (City c : foundCities) {
|
||||
citiesToFill.add(c);
|
||||
if (resultMatcher.isCancelled()) {
|
||||
return citiesToFill;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.text.Collator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.LogUtil;
|
||||
|
@ -87,8 +87,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
|
|||
final NamesAdapter namesAdapter = new NamesAdapter(new ArrayList<T>(), createComparator()); //$NON-NLS-1$
|
||||
setListAdapter(namesAdapter);
|
||||
|
||||
collator = Collator.getInstance(Locale.US);
|
||||
collator.setStrength(Collator.PRIMARY); //ignores also case
|
||||
collator = LogUtil.primaryCollator();
|
||||
|
||||
|
||||
progress = (ProgressBar) findViewById(R.id.ProgressBar);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.City.CityType;
|
||||
|
@ -54,10 +54,9 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
|
|||
|
||||
@Override
|
||||
protected Comparator<? super City> createComparator() {
|
||||
final Collator cs = Collator.getInstance();
|
||||
final boolean en = getMyApplication().getSettings().usingEnglishNames();
|
||||
final StringMatcherMode startsWith = CollatorStringMatcher.StringMatcherMode.CHECK_ONLY_STARTS_WITH;
|
||||
return new CityComparator(startsWith, cs, en);
|
||||
return new CityComparator(startsWith, en);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,13 +174,13 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
|
|||
|
||||
private final class CityComparator implements Comparator<City> {
|
||||
private final StringMatcherMode startsWith;
|
||||
private final Collator cs;
|
||||
private final net.osmand.Collator cs;
|
||||
private final boolean en;
|
||||
|
||||
private CityComparator(StringMatcherMode startsWith, Collator cs,
|
||||
private CityComparator(StringMatcherMode startsWith,
|
||||
boolean en) {
|
||||
this.startsWith = startsWith;
|
||||
this.cs = cs;
|
||||
this.cs = LogUtil.primaryCollator();
|
||||
this.en = en;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.osmand.NativeLibrary;
|
|||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -32,6 +33,9 @@ public class NativeOsmandLibrary extends NativeLibrary {
|
|||
System.loadLibrary("gnustl_shared");
|
||||
log.debug("Loading native cpufeatures_proxy..."); //$NON-NLS-1$
|
||||
System.loadLibrary("cpufeatures_proxy");
|
||||
// log.debug("Loading load routing test..."); //$NON-NLS-1$
|
||||
// System.loadLibrary("routing_test_jar");
|
||||
// testRoutingPing();
|
||||
if(android.os.Build.VERSION.SDK_INT >= 8) {
|
||||
log.debug("Loading jnigraphics, since Android >= 2.2 ..."); //$NON-NLS-1$
|
||||
System.loadLibrary("jnigraphics");
|
||||
|
@ -100,4 +104,5 @@ public class NativeOsmandLibrary extends NativeLibrary {
|
|||
|
||||
public static native int getCpuCount();
|
||||
public static native boolean cpuHasNeonSupport();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue