diff --git a/OsmAnd/res/layout/dash_search_fragment.xml b/OsmAnd/res/layout/dash_search_fragment.xml
index 95408d7fd7..df0f6a8f7e 100644
--- a/OsmAnd/res/layout/dash_search_fragment.xml
+++ b/OsmAnd/res/layout/dash_search_fragment.xml
@@ -7,12 +7,16 @@
android:background="@drawable/bg_cardui"
android:orientation="vertical" >
-
+
+
+
+ Nearest road was not found
Home
Use secure connection with server
Use https
diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java
index beff07b766..80a10c6224 100644
--- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java
@@ -42,35 +42,32 @@ public class CurrentPositionHelper {
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles());
}
- public synchronized RouteDataObject runUpdateInThread(double lat , double lon) {
+ public synchronized RouteDataObject runUpdateInThread(double lat, double lon) throws IOException {
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false);
- try {
- if(ctx == null || am != app.getSettings().getApplicationMode()) {
- initCtx(app);
- if(ctx == null) {
- return null;
- }
- }
- RouteSegment sg = rp.findRouteSegment(lat, lon, ctx);
- if(sg == null) {
+ if (ctx == null || am != app.getSettings().getApplicationMode()) {
+ initCtx(app);
+ if (ctx == null) {
return null;
}
- return sg.getRoad();
- } catch (IOException e) {
+ }
+ RouteSegment sg = rp.findRouteSegment(lat, lon, ctx);
+ if (sg == null) {
return null;
}
+ return sg.getRoad();
+
}
private void scheduleRouteSegmentFind(final Location loc){
if(calculatingThread == Thread.currentThread()) {
- lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude());
+ lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
} else if(calculatingThread == null && loc != null) {
Runnable run = new Runnable() {
@Override
public void run() {
try {
- lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude());
+ lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
if (lastAskedLocation != loc) {
// refresh and run new task if needed
getLastKnownRouteSegment(lastAskedLocation);
@@ -85,6 +82,15 @@ public class CurrentPositionHelper {
}
+ protected RouteDataObject runUpdateInThreadCatch(double latitude, double longitude) {
+ try {
+ return runUpdateInThread(latitude, longitude);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
private static double getOrthogonalDistance(RouteDataObject r, Location loc){
double d = 1000;
if (r.getPointsLength() > 0) {
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java
index d4f4afbfd7..0310bde0a6 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java
@@ -216,7 +216,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
public RouteDataObject findRoute(double lat , double lon) {
- return currentPositionHelper.runUpdateInThread(lat, lon);
+ return currentPositionHelper.runUpdateInThreadCatch(lat, lon);
}
public void resumeAllUpdates() {
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java
index 8de9cfefe7..d00207c490 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java
@@ -1,18 +1,21 @@
package net.osmand.plus.dashboard;
+import net.osmand.plus.OsmAndAppCustomization;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.search.SearchActivity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AutoCompleteTextView;
+import android.widget.EditText;
import android.widget.TextView;
-import net.osmand.plus.OsmAndAppCustomization;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.search.SearchActivity;
/**
* Created by Denis on 24.11.2014.
@@ -25,6 +28,7 @@ public class DashSearchFragment extends DashBaseFragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false);
setupButtons(view);
+ // TODO cache typeface ?
Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Medium.ttf");
((TextView) view.findViewById(R.id.search_for)).setTypeface(typeface);
return view;
@@ -39,6 +43,8 @@ public class DashSearchFragment extends DashBaseFragment {
private void setupButtons(View view){
final Activity activity = getActivity();
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
+// EditText searchText = (EditText) view.findViewById(R.id.search_text);
+// searchText.addTextChangedListener(textWatcher);
(view.findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java
index 04beefd12c..ef9f2bdef5 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java
@@ -27,6 +27,7 @@ import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
public class AvoidSpecificRoads {
private List missingRoads;
@@ -143,14 +144,23 @@ public class AvoidSpecificRoads {
}
private void findRoad(final MapActivity activity, final LatLon loc) {
new AsyncTask() {
+ Exception e = null;
@Override
protected RouteDataObject doInBackground(LatLon... params) {
- return app.getLocationProvider().findRoute(loc.getLatitude(), loc.getLongitude());
+ try {
+ return app.getLocationProvider().findRoute(loc.getLatitude(), loc.getLongitude());
+ } catch (Exception e) {
+ this.e = e;
+ e.printStackTrace();
+ return null;
+ }
}
protected void onPostExecute(RouteDataObject result) {
- if(result != null) {
+ if(e != null) {
+ Toast.makeText(activity, R.string.error_avoid_specific_road, Toast.LENGTH_LONG).show();
+ } else if(result != null) {
getBuilder().addImpassableRoad(result);
RoutingHelper rh = app.getRoutingHelper();
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
diff --git a/OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java b/OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java
index e50acfc5a9..ca3dd7e2e8 100644
--- a/OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java
+++ b/OsmAnd/src/net/osmand/plus/views/OsmAndMapLayersView.java
@@ -6,7 +6,6 @@ import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import android.view.SurfaceHolder;
import android.view.View;
public class OsmAndMapLayersView extends View {