Remove thread, add sync

This commit is contained in:
Alexey Kulish 2016-03-30 18:03:26 +03:00
parent 1452f77488
commit eb6e9efa4b

View file

@ -1,5 +1,7 @@
package net.osmand.plus;
import android.os.AsyncTask;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@ -59,16 +61,29 @@ public class CurrentPositionHelper {
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
}
private boolean scheduleRouteSegmentFind(final Location loc, final boolean storeFound, final ResultMatcher<GeocodingResult> geoCoding, final ResultMatcher<RouteDataObject> result) {
boolean res = false;
if (loc != null) {
new Thread(new Runnable() {
new AsyncTask<Void, Void, Void>() {
@Override
public void run() {
protected Void doInBackground(Void... params) {
try {
processGeocoding(loc, geoCoding, storeFound, result);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}.execute((Void) null);
res = true;
}
return res;
}
private synchronized void processGeocoding(Location loc, ResultMatcher<GeocodingResult> geoCoding, boolean storeFound, final ResultMatcher<RouteDataObject> result) throws IOException {
final List<GeocodingResult> gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude(),
geoCoding != null);
if (storeFound) {
@ -84,14 +99,6 @@ public class CurrentPositionHelper {
}
});
}
} catch (IOException e) {
e.printStackTrace();
}
}
}, "Geocoding...").start();
res = true;
}
return res;
}
protected void justifyResult(List<GeocodingResult> res, final ResultMatcher<GeocodingResult> result) {